Need Help With A Program
Link2Time
Posts: 5
What I'm trying to do is confine my Boe-Bot within a Circle colored Black with the edge of the circle in white. I want my boe-bot to reverse when the two Photoresistors see white. I'm having trouble getting it to work. If you have problems understand what I'm asking please reply and I'll try my best to answer.
' {$STAMP BS2} ' {$PBASIC 2.5} '----[noparse][[/noparse]Variables]----- timeLeft VAR Word timeRight VAR Word timeLeftB VAR Word timeRightB VAR Word timeLeftW VAR Word timeRightW VAR Word counter VAR Word counter = 0 '----[noparse][[/noparse]Main Routine]---- DO IF (IN1 = 0) THEN counter = counter + 1 PAUSE 200 ENDIF IF (counter = 0) THEN GOSUB Read_Black ELSEIF (counter = 1) THEN GOSUB Read_White ELSEIF (counter > 2) THEN GOSUB Navigate ENDIF LOOP '-----[noparse][[/noparse]SubRoutines]----- Read_Black: timeLeftB = timeLeft timeRightB = timeRight RETURN Read_White: timeLeftW = timeLeft timeRightW = timeRight RETURN Navigate: IF (timeLeft > timeLeftW) AND (timeRight > timeRightW) THEN PULSOUT 13, 650 PULSOUT 12, 850 ELSEIF (timeLeft > timeLeftW) THEN PULSOUT 13, 850 PULSOUT 12, 850 ELSEIF (timeRight > timeRightW) THEN PULSOUT 13, 650 PULSOUT 12, 650 ELSE PULSOUT 13, 850 PULSOUT 12, 650 PAUSE 20 ENDIF RETURN
Comments
If there were some comments, including definitions of what the pin ports were, and a schematic to show what external parts were being used, and where, you might get some answers.
Just by way of example, where are the photo-resistors being "read"? The only pin port that's being used is pin port 1, and one would expect more in an ordinary ring-sensing set-up.
Another odd part of your program is when you check the "counter" variable. You check for 0, 1, and greather than 2. What is supposed to happen if counter is equal to 2? If you want to check for equal to 2 and greater than 2, you can use both comparison operators " => " to indicate the two conditions.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Involvement and committment can be best understood by looking at a plate of ham and eggs. The chicken was involved, but the pig was committed. ANON
Yeah I didn't know how to include my PhotoResistors in this but the pins I'm using are Pin3 and Pin6. I also changed the counter to what you have suggested. I don't know about the rest of the stuff because I'm a noob with at working with this.
If you took some sample program as a starting point, how about giving us that background?
This has nothing to do with whether you have Stamp or Robotics experience or not. It's about how to ask for help. If you're paying someone to help you, they'll generally be accommodating ... after all, you're paying for their time and you can use it well or waste it. If you're asking someone to volunteer their time and effort (as is true here), you need to provide lots of information including your intentions, observations, assumptions, etc. You'll get faster and better answers and people will be more interested in helping.
What I want:
I'm using a button to record black and white for me and in the code the Boe-Bot is supposed to avoid white but move on black.
Button Press 1: Record Black Color With Photo Resistors
Button Press 2: Record White Color With Photo Resistors
Button Press 3: Navigates
When both Resistors see White the reverse 180
When left sees White it turns left
When right sees White it turns right
-none of that is happening for me.
When it Navigates I want it to avoid white but move on black, but what really happens is that it keeps moving no matter what color is under my photo resistors.
Here are some images:
Darn photoresistors
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
I send you a PM·
·
Franklin
So, you screw up and it's their (our) fault? Next time maybe you won't get any help with an attitude like that. I may be wrong, others here aren't as bitter as I. [noparse];)[/noparse]
You could not have said it any better than that··
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 4/3/2008 4:48:26 PM GMT