This program is for the bumper robot.
It has a front bumper connected to port A pin A1
and a back bumper connected to port A pin A2.
When the robot collides with an object on the front bumper, it will first of all go backwards and secondly it will do a slight turn so as to avoid the object in the future. Likewise when it hits an object in the rear it will move forwards and do a slight turn.
Program
---
Bumper Robot Program
This program is for the bumper robot.
It has a front bumper connected to port A pin A1
and a back bumper connected to port A pin A2.
---
prog_vars =
-- Keep track of the number of bumps.
d/front 0
d/back 0
-- Track to no of times we have run.
d/count 0
prog_vars.
prog_start =
print "Bumper Robot Program Setup"
-- Reset the buttons
rstb
-- Setup the front bumper.
-- Go back and turn left.
btp a1 bms -50|lms -10|d500|lms -50|inc /front
-- Setup the back bumper.
-- Go forward and turn right.
btp a2 bms 50|rms 10|d500|rms 50|inc /back
-- Set both motors to forwards at 50
bms 50
prog_start.
prog_loop =
-- main program loop
-- Increase the /count by 1
inc /count
-- Check if we shoukd exit.
any /count > 1000 -> exitprog
prog_loop.
prog_stop =
print "Bye Front /front Back /back"
-- Clear the buttons
rstb
-- Stop the robot
stop
prog_stop.