Вы находитесь на странице: 1из 1

Implementation plan and debugging procedure My program was creating by first writing one small piece of the program

that would satisfy one condition, testing it and then adding on another small piece that would fulfill another condition. This process continued until I had a fully functional program. First, I defined the sensors and motors and created the global variables. Next I created the setup() function where the sensors were assigned functions. In setup(), the EYE takes a threshold reading while it is held over the green square. Sounds were added to tell the user when the reading starts and ends. The BLACK and WHITE variables were assigned values that were below and above the GREEN value, respectively. Next, I created the task follow_line. This task would allow the robot to follow the left side of the black line. The BLACK and WHITE variables are used to control the lateral movement of the robot. Incorporation of the touch sensors was the next step. I created the task brick() which, if either touch sensor became unpressed, the follow_line task would stop. The robot would back up, make a 180 degree turn and then start the follow_line task. In terms of debugging, I had to change the turn time a few times to find a time that would yield a 180 degree turn. The next step was to get the robot to stop on the green square. I made a while loop that constantly checked the EYE for a range of values near GREEN. If the EYE detected a value in this range, then after a short period of time, it would add a value of 1 to the count value and play a sound. This process would repeat until the count reached a certain number before stopping follow_line and turning off the robots motors. I used sounds to help me see when the EYE was seeing certain values which helped when adjusting wait times and number of counts needed. Determining a precise wait time and number of counts was also difficult as the EYE picked up values that would be considered green when it was in a region of BLACK/WHITE transition. Increasing the number of counts ensured that the EYE was seeing GREEN consistently before turning off the line_follow task. After all of these tasks were created, I made the task main() which contained setup(), follow_line, brick and green tasks. In main(), I also set the power level to a lower level. This played a significant role in the debugging procedure. I had almost finished writing my entire program when the batteries to my robot died. I replaced the batteries and tested my robot. The robot moved very quickly and did not follow the line very well. I turned down the power to a lower level to create a speed similar to that of a low battery level. A slower speed was necessary to make the follow_line task work well.

Вам также может понравиться