Introduction: Train Programming Enhancements in MATLAB
The goal of this programmed system is to look at a small scale Arduino and apply the coding on a bigger scale to potentially enhance certain safety features of Amtrak Railroad systems. In order to do this, we have added a soil moisture sensor, temperature sensor, optical detector/ photo resistor, and an LED light. The soil moisture sensor and temperature sensor are beneficial because they will allow control of the speed during inclement weather. The optical detector will be used to detect the speed of the train, and the LED light is used to resemble the current blinking light that appears if a train is nearby.
· DS18B20 Digital Temp Sensor
· Optical Detector/ Photo-transistor
· Soil Moisture Sensor
· 4.7 KOhmResistor
· 330 Ohm Resistor x2
· 10 KOhm Resistor
· Cables/Jumpers x17
· USB Connector Cord
Four separate procedures will follow to display the correct wiring and coding for each enhancement that way you can add as many as you would like when building your own.
Step 1: Boot Up Your Computer, and Open MATLAB to Prepare for Coding!
Step 2: Adding the Soil Moisture Sensor
Start by connecting the VCC pin to the 5V supply. Next connect the ground pin to ground. After this you will connect the AO pin to the analog 1 pin on the Arduino. Once you have connected the Arduino to MATLAB, initiate an analog read for the analog 1 pin then run the program. If having trouble, you can just copy the code below.
Step 3: Adding the Temperature Sensor
Connect the grey and red wire both to shared ground. Then you will connect the yellow wire to the PWM pin number 10 and to a 4.7 Kohm resistor. This will then connect to your 5V supply. To code this function, open matlab>add-ons> get hardware support packages. Once in support packages search Dallas 1-wire protocol and download this. Reference this article in order to set up your code. https://in.mathworks.com/examples/matlab/community/19771-communicate-with-1-wire-reg-devices-on-arduino-reg-hardware
Step 4: Adding the Optical Detector
Connect both anodes to shared ground. Then connect the cathode on the front position of the sensor to analog pin 0 on the Arduino and to a 330 ohm resistor which then connects to the 5V supply. Next connect the rear cathode to a 10 Kohm resistor and then to the 5V supply. For coding this, initiate another analog read for pin 0 and run the program. The full code is provided in this file.
Step 5: Adding a LED Light
Connect the anode of the LED to a 330 ohm resistor. You will then connect this to ground. Next connect the cathode of the LED to the PWM pin 13 on the Arduino.
Step 6: The FINAL Product
This is the overall look of what your Arduino and code should look like with all the enhancements included!
As an addition to your project, you can also 3D print a cow to show how a real life blinking light stops oncoming traffic so that the train can pass through, and then once the train is gone the cow may proceed with its set course. Here is the link to 3D print this particular cow.
We have a be nice policy.
Please be positive and constructive.