You are on page 1of 2

Program Table

Item
EYE
Sonic
Touch
int toobright

int green

void setup()

hunt()

detect_bump()

toss

Description
Preprocessor Directives
Assigns the light sensor to port 1
Assigns the ultrasonic sensor to port 2
Assigns the touch sensor to port 3
Assigns a value for the white balls, so the bot will
leave the white balls when it senses them using
the light sensor.
Assigns a value for green that when sensed, the
bot will reverse until it senses the black wall and
will then toss the ball over the wall.
Inline functions/Tasks/Values
Before the bot starts, we have to hold a green
ball in front of the light sensor and then a white
ball for the sensor to recognize the difference
between the values. A sound plays for three
seconds after sensing the green ball then another
sound for three seconds after the white ball to
differentiate between the balls and to confirm
that it has sensed both balls. The rest of the
program then commences.
This task is for the bot to move around the area
randomly. This task will go on throughout the
whole program. The bot will move forward
randomly using both motors at 75% power for 2
seconds then will reverse randomly using motor
B at 75% power for 1 second.
In this task, the bot will first assign the touch
sensor to port 3. Then, when the touch sensor
hits an obstacle, the task hunt () will stop. The
bot will reverse using both motors at 75% power
for 0.5 seconds, then will move forward using
motor A at 75% power for 0.85 seconds, after
which task hunt() will start again.
This function assigns the ultrasonic sensor to port
2. Then, the bot rotates the bot utilizing port C at
30% power at -20 degrees. Then the bot will
reverse the motors direction using both motors
at 55% power at 0 degrees until the ultrasonic
sensor is less than equal to the value of 5. Next, a
sound of frequency 1350 for a duration of 0.75
seconds will play. Following that, both motors
will turn off (A&B), then the motor will rotate
using motor C at 100% power at -85 degrees for
0.5 seconds. Finally, the motor will rotate using

greentask()

main()

motor C at 20% power at 110 degrees, and turn


motor C off.
This task is for the bot to sense the green balls. If
it senses the balls, it will reverse and toss the
balls then will start hunting again.
This task is the main program task that the bot
will use to run. First, the setup will commence,
then the hunt will start along with the
detect_bump() task, after which greentask will
start.

You might also like