Week 9

This week I finished the program. And by finish I mean I got the program to a state where it will follow the line, and complete all actions it is given. As it currently stands, there ARE actions added for Blue, Green and Red, the 3 colours featured on the track.

However, they aren’t without problems. The current program makes the robot pick up an object (a crude cardboard square) upon detection of Blue. The problem with this function is that the robot’s arm has a tendency to get stuck (due to the design and structure of the robot). When it gets stuck, the robot stops dead until the arm either falls off, or the program is stopped and restarted. I am currently looking for a way for this to be fixed. The function is presented below.


It is initialized via the boolean variable, which is set to true via the main function upon detection of blue. The reason for having the function in a separate instance is so that their can be a delay which prevents the function from being initialized in the first 3 seconds, or within 13 seconds of any previous initialization thereafter.

Upon detection of Green (which due to the current track design, is after Blue) the robot turns, drives off the track, drops the cardboard square it is carrying, and then reverses, turns around, and finds it’s way back to the line. The problem here is that based on the robots movement (zig-zagging across the right edge of the line), the robot sometimes misses the green circle. This can hopefully be remedied by adding some green tape over the black part around the circle. There isn’t really any need to show the program for this, as it is just a string of simple motor command blocks.

The Red circle is right at the end of the track. The robot counts how many times it detects it as the number of laps. This value is then compared with the a value for maximum number of laps. This value for maximum number of laps is set at the beginning, where the user sends a value via bluetooth to the robot. If the user chooses to skip this with a button, the default value of 3 laps will be taken (this default value may need to be changed at a later date, as the robot takes a fairly long time to get around the whole track). The function is presented below:


This function is also part of a separate instance, again so that it can have a delay in place that prevents it being initialized within 3 seconds of being initialized previously.

In addition to the colour functions, I added a small segment of code that uses the IR sensor. This code runs parallel to the main code, and upon detection of an object (say the user’s hand) at close range, stops both large motors. This comes in handy when the user needs to stop the program or move the robot mid-execution, as they can simply hold their hand in front of it and the robot will stop. This IR function is presented below:


Finally, here is a demonstration of the Blue and Green functions combined for the final game:

The group member who rarely turns up actually made an appearance on the Friday session this week, however he seemed more intent on sleeping than on doing any work. Two of the other members did not show up, and did not give any notice to the group about their absence.

Week 9

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s