The purpose of the train project lab is to give students hands-on experience with programming. Students use algorithms and develop pseudo code to create a MATLAB program which will eventually run a train. Throughout the process students gain experience working with others, making an online project notebook, and using multiple programming techniques.
In the beginning, students were required to write an initial pseudo code for the final program. Students were also required to do basic testing to collect data. This helped familiarize students with how the entire system works. To complete the datasheet, students needed to determine which COM port the Arduino was connected to, the value where the crossing gate was vertical, and which LED turned on first (left or right). Also, students found and recorded the values where the sensor was obstructed and unobstructed, and they had to determine what caused the differences in these values. The final part of the datasheet required students to calculate and record the train speed, motor speed, and time it took for the train to complete half of a circuit. To collect this data, students created a short MATLAB program which included tic and toc commands, and calculated the train speed using the circumference of the track.
Students were required to program their train to move around the track at varying speeds. The train needed to go faster in the rural part and slower in the urban part. As extra credit, students were given the task of turning the LED lights on and off at the arrival and departure gates. For more extra credit, students were asked to make the crossing gate move up and down, and to make the lights on it turn on and off. For a third extra credit opportunity, students were asked to input a line of code that would ask the user to input a speed. To do this, students would need to develop an algorithm that would adjust the speed if the train was going too fast or too slow.