Introduction: Safer Better: Making Train Stations Safer
Many train stations today are unsafe due to a lack of security, barriers, and warning of the train coming in. We saw a need for that to be fixed. In order to solve this problem we created Safer Better. We used vibration sensors, motion sensors, and an emergency alarm system on an Arduino Uno to add safety to a train station.
- Arduino Uno
- Jumper Wires
- PIR Motion Sensor
- Piezo Vibration Sensor
- LCD Screen
- Piezo Speaker
- Physical Switch
- Soft Potentiometer
- 330 ohm resistor
By: Jacob Wimmer, Olivia Crawley, Jin Kim
Step 1: Wire the Board
We wired our Arduino like the above diagram.
Step 2: 3D Print LCD Stand
We 3D printed a stand for our LCD screen for better visability.
Step 3: Connect to Arduino in Matlab
The first step to writing our code was to connect our Arduino board to Matlab. This is done by creating an Arduino object. We used the following code:
a = arduino('/dev/tty.usbmodem14201','Uno','libraries','ExampleLCD/LCDAddon');
Step 4: Write Code in Matlab
We created a program in Matlab to run our Arduino. After initializing our LCD screen, we wrote code to control our train station. We used inputs such as a vibration sensor, motion sensor, and physical switch to produce a variety of outputs. These inputs, outputs, and corresponding code will be explained in the steps below.
Step 5: Vibration Sensor
The vibration sensor is an analog sensor and therefore used the Matlab function readVoltage.
val_vibro = readVoltage(a,'A0'); T
he readVoltage function returned a range of values, but we determined that a value above 0.5 was a decent vibration and so we used that as our base value. If the voltage was above 0.5, it means the train is coming into the station. When this value was detected a message is sent to the LCD screen. The message on the LCD screen is a way of communicating to people at the station that a train is coming.
We wrote on our LCD screen using the following code:
if val_vibro <= 0.5;
elseif val_vibro > 0.5;
printLCD(lcd,'Train In 3 Min');
Step 6: PIR Motion Sensor
The PIR motion sensor is used to ensure the operator knows of obstacles along the train tracks. The sensor takes pictures and compares the newest picture to the last one taken and if anything has moved Matlab will return a value of 1. When something is detected on the tracks a graphical user interface (GUI) pops up to notify the train operator that something is on the tracks. The operator then has the option to stop the train or to continue. After selecting the desired option, a confirmation message is displayed.
The following code was used for the motion sensor:
if val_opt == 1;
d1 = 'An object has been detected on the tracks in the station';
op_input = questdlg(d1,'Operator Message','Stop Train','Keep Moving','Keep Moving');
b1 = strcmp(op_input,'Stop Train');
b2 = strcmp(op_input,'Keep Moving');
if b1 == 1
elseif b2 == 1
elseif val_opt == 0;
Step 7: Physical Switch
We also think that train stations need to have more security features. We decided to have a switch that would sound an alarm at the station. We did this by using a physical switch. When this switch is turned on an alarm sounds through a speaker.
We did this with the following code:
if s_val == 1
for i = 1:10
Participated in the
First Time Author