Toll Booth Revisited Procedures
The toll booth for the micro-controller activity was the same as the previous state machine. The difference this time was in the method used to operate the booth arm. Previously, we had constructed a state machine, but this time we used a microcontroller and coding through the Arduino UNO platform.
The logic behind the manipulating the gate arm was simple. When the arm was raising or lowering, the motor needed to be on until it hit one of the two limit switches, which would kill power to the motor. Although the logic was "simple" it took me quite a long time to write the proper code. This was mainly because coding is not my background, and my experience with it is minimal.
To start the code, I began by identifying the constants that I would be using to operate the toll booth. Once the pins were assigned, I determined whether each pin needed to be an input or an output in the setup. This part was extremely easy and the project was rolling along smoothly.
From here it was time to start writing the loop to control the gate arm. I wrote a few loops unsuccessfully, and asked a classmate for help. My classmate taught me a great way to look at the situation by using a "while" command. Initially, I wrote a command for each action happening. For instance, when the button was pushed, the motor arm would get voltage and raise the arm. Also, the switches and LED would see zero volts, unless a limit switch was pressed, causing the switch and LED to both go high. The way I was writing the code was much longer, which resulted in more room for error. Using the while command, I simply had to identify the starting states of the motors, switches, and LED. Then when the button was pressed, I identified everything else that was happening WHILE the motor was driving (as seen to the left). This tip was extremely helpful, and reduced the amount of code in my loop incredibly.
The logic behind the manipulating the gate arm was simple. When the arm was raising or lowering, the motor needed to be on until it hit one of the two limit switches, which would kill power to the motor. Although the logic was "simple" it took me quite a long time to write the proper code. This was mainly because coding is not my background, and my experience with it is minimal.
To start the code, I began by identifying the constants that I would be using to operate the toll booth. Once the pins were assigned, I determined whether each pin needed to be an input or an output in the setup. This part was extremely easy and the project was rolling along smoothly.
From here it was time to start writing the loop to control the gate arm. I wrote a few loops unsuccessfully, and asked a classmate for help. My classmate taught me a great way to look at the situation by using a "while" command. Initially, I wrote a command for each action happening. For instance, when the button was pushed, the motor arm would get voltage and raise the arm. Also, the switches and LED would see zero volts, unless a limit switch was pressed, causing the switch and LED to both go high. The way I was writing the code was much longer, which resulted in more room for error. Using the while command, I simply had to identify the starting states of the motors, switches, and LED. Then when the button was pressed, I identified everything else that was happening WHILE the motor was driving (as seen to the left). This tip was extremely helpful, and reduced the amount of code in my loop incredibly.
-final product-
-errors-
Aside from the coding errors already mentioned, the only other problems encountered where with the push button switches on the breadboard. The push-buttons were always seeing a logic high, regardless of the state of the button. Perplexed by the issue, a SPDT switch was used in place of a push-button. It does irk me that I did not troubleshoot the push-button switch to build the proper circuit. After a two weeks of intense training, and a struggle with coding on the final project, I uncharacteristically gave in to using a substitute part instead of troubleshooting the original issue.