Bumper sensors

How do I get the bumper sensors torun the course that is suggested in the VEX programming section of the Manuaul. The robot should hit an object go left, hit an object go right, hit another object go right, hit another object go left and stop after a short period of time. if anybody has a code for this or can give me a sample code for this it would be a big help.

thank you.

I’m not going to give you the code, but i’ll give you some hints. Try them, see what happens, tweak… All this asusmes a squarebot.

For autonomous behavior, you need to set up a WHILE loop. I’d suggest making the parameter equal to “1==1”, which means “While 1 is equal to 1, do this”. Since 1 is always equal to 1, it does that forever.

Next, define a variable to hold the state of the bumper switch. Use an Integer (INT)

As the first thing in the WHILE loop, set the two motors so the bot drives forward.

You need a second loop inside the first. Check for the value of the bumper switch inside this loop. WHILE the bumper switch is not pressed, keep moving forward - as soon as it gets pressed, turn left (both motors have the same value, like 255 or 0, and WAIT a few hundred microseconds for the turn to complete), then drop out and move forward again.

A second loop, but this time when the bumper switch is pressed turn right. And so on.

Try to make the first part - turn left after hitting the bumper and move forward again - work well, and that can be almost copied 100% for all the other turns.

Good luck, and post your code, working or not.

Don