Simple Boe-Bot program not working
kickflipper11
Posts: 4
Hello
I am new to programming and I have been working on a really simple program for the Boe-Bot. I currently have a program that drives the boebot when a button is pressed. It uses the feelers to navigate, so it's in the format of
do
If (IN5 = 0) then
backup, turn
elseif(IN7 = 0) then
backup, turn
else
drive
loop
I didn't wanna post the actual code so its not confusing, but I can if it would help. Currently, it works fine, when the program is uploaded, the robot does not move until the button is pressed. However, I want to make it so that when the button is pressed again the boebot stops. I added another elseif stating that when the button is pressed (IN12 = 0), the whole program is called again with GOTO programname. However, just adding this new elseif ruins the drive program, and it won't go at all. Ive tried so many different variations, but nothing seems to work and I'm getting pretty frustrated, since it makes perfect sense in my head.
Am I going about this wrong? Are there any problems you could see with this approach? Thank you very much for any help you can offer, this is driving me crazy haha =/
I am new to programming and I have been working on a really simple program for the Boe-Bot. I currently have a program that drives the boebot when a button is pressed. It uses the feelers to navigate, so it's in the format of
do
If (IN5 = 0) then
backup, turn
elseif(IN7 = 0) then
backup, turn
else
drive
loop
I didn't wanna post the actual code so its not confusing, but I can if it would help. Currently, it works fine, when the program is uploaded, the robot does not move until the button is pressed. However, I want to make it so that when the button is pressed again the boebot stops. I added another elseif stating that when the button is pressed (IN12 = 0), the whole program is called again with GOTO programname. However, just adding this new elseif ruins the drive program, and it won't go at all. Ive tried so many different variations, but nothing seems to work and I'm getting pretty frustrated, since it makes perfect sense in my head.
Am I going about this wrong? Are there any problems you could see with this approach? Thank you very much for any help you can offer, this is driving me crazy haha =/
Comments
Mark
Ok, there is the program (in a .txt file), I hope it works. Anyway, I have a button set up on the bread board of the BASIC stamp. I have tested it with the DEBUG command in a test program: when it's pressed, it returns 0, and when it isn't, it returns 1. I simply want the button to be used as a start/stop for a drive program.
When I had just used the button as a way to start the program, it worked fine. I turned on the BoeBot, waited however long I wanted, then pressed it and it ran fine. With the new program I uploaded (the one that is supposed to start and stop the boebot), I turn on the Boebot and press the button and it twitches a little bit and then stops.
The worst I expected was for the button to only function as a starter, just not stop it. Now, it won't do either. Thanks a lot for the replies, I really appreciate it.
It seems to me that you need to adust the PAUSE time in this section. I believe your code is taking to long to get back to the PULSOUT parts running through all the IF statements. Remember a servo needs to recieve pulses every 20-40 ms to work properly. First, I would try commenting PAUSE out and see what happens. If that doesn't work maybe try PAUSE 5 and then PAUSE 10.
Tony
On the Basic Stamp it seems I've never had good luck with many if statements, it just causes problems. I haven't worked with the Stamp enough recently to know for sure but I think the select case command will suit you just fine. Normally one would use a single variable for it, but I'm sure you could ask some of the pro's here if you could select a case based on the button inputs. If you don't know about the case command I advise you look it up in the Stamp manual, I haven't used it myself enough to teach you.
Hope this helped,
Derrick