On Button A, On Button B and On Button A+B
In this example we use the
On Button
event blocks a lot. They allow us to break out different functions we want
without messy
if
statements.
In this program the
On Button A
event block resets the calibration value for the table surface for the robot to use
as a comparison value and also sets the servo positions to 90 degrees.
The
On Button B
block is used to set servo position to 45 degrees.
Finally the
On Button A+B
event block is used to run the program.
If / Then Statements
You may notice that there is a few
if / then
blocks inside of the if statement in the
forever
block. This will aid
your Battle Bot in making decisions and knowing what it has to do next.
What You Should See
Before running the program, make a thick line (about 12" wide x 6" long) using black electrical tape. This is where
your robot will meet with an opposing robot.
When the code initializes, the servo "arms" will move into a starting position and take initial readings for your line
sensors to establish a comparison point to the ground environment. Make sure to calibrate it with a black line
before starting. Then place each robot at an equal distance away from the line.
Initially, the Battle Bot will not move. Press on buttons A and B at the same time to run the program. The robot will
move forward if none of the line sensors detect the black line. If the center line sensor detects a black line, the
Battle Bot will immediately start both servos and move backwards. If the left or right line sensors detect a dark
surface, the side that detected it will have the corresponding jousting lance start to move while turning away from
it. So your Battle Bot is prepared to defend itself from any oncoming situation!
i
b t kit E 5
i
b t kit E 5