Taking a classic battery operated train set, actuated using a small PMDC motor, the task is to add functionalty with numerous sensing and motor driver sub-systems. This is a group project in which my role was testing all of the circuitry and writing of code.
- Control speed and direction of train with joystick and H-Bridge
- Communicate wirelessly between a Joystick and train motor
- Design a collision avoidance system
- Design a colour recognition system to stop on red and go on green
- Use PID control to apply a velocity motion profile
The Transmitter code for the Nano simply takes the forward/backward input from the joystick and wirelessly transmits it to the Reciver.
The Reciever code for the MEGA calls the functions to run the collision detectance and colour sensor, a series of if statements check there's no obsticles or red card displayed. If these tests are passed and a green card is show to the train a boolean value is made True, this allows the train to then operate indefinetly, until a red card or collision is present.
The code is broken down to
- Colour Sensor
- Distance Sensor
- Motor Control
- Reciever
The seperation of each code allows for easy debugging and clean code, each segment refers to one of the sensors, the control of the motor or reciveing of wireless signal and is then all called in the main file of code.
Each Folder will contrain one or two codes for the two arudinos used, whole folders should be downloaded for each microcontroller and ran in Arduino IDE
AllWiredTestIncludes code for Ardunio MEGA testing the motor and sensors without the use of wirelessWirelessTestIncludes code for Ardunio MEGA and Nano, this was to test motor control over wireless signal but doesn't include the use of sensors



