Help with Program Please
Bill Kenny
Posts: 15
Hello All,
·
I was wondering if someone could help me try to figure out some programming I am having trouble with.
·
I have the Boe-Bot kit and am trying to put it in a toy tank like vehicle. I have done that and it works great except the feature I want to add are stumping me.
·
This is what I am trying to do;
·
I am using the whiskers program (tweaked a little) I will post below. It is hunting for a path to avoid objects. When it encounters one, I would like a red LED in the barrel to flash once and then activate a separate sound board I have, and then turn as usual to avoid the object. Each time it needs to reverse to avoid the objects is when I need the led flash and the sound to go off. The sound board is from radio shack that is capable of 20 seconds of your recorded sound. I have a 3 second explosion with the led light up to simulate firing the tank. Basically the purple exposed wires are just for a switch.
·
Any help?
·
Here's the code;
' Robotics with the Boe-Bot - RoamingWithWhiskersModIRwLED.bs2
' Adapt RoamingWithWhiskers.bs2 for use with IR pairs.
' {$STAMP BS2}·················· ' Stamp directive.
' {$PBASIC 2.5}················· ' PBASIC directive.
DEBUG "Program Running!"
'
( Variables )
· irDetectLeft······ VAR· Bit
· irDetectRight····· VAR· Bit
· pulseCount········ VAR· Byte······· ' FOR...NEXT loop counter.
'
( Initialization )
FREQOUT 4, 2000, 3000················ ' Signal program start/reset
'
( Main Routine )
DO
· FREQOUT 8, 1, 38500················ ' Store IR detection values in
· irDetectLeft = IN9················· ' Bit variable
· FREQOUT 2, 1, 38500
· irDetectRight = IN0
· IF (irDetectLeft =0) AND (irDetectRight = 0) THEN
··· HIGH 10·························· ' LED
··· HIGH 1··························· ' LED
··· GOSUB Back_Up···················· ' Both IR pairs detect obsticle
··· GOSUB Turn_Left·················· ' Back up & U-turn (left twice)
··· GOSUB Turn_Left
· ELSEIF (irDetectLeft = 0) THEN····· ' Left IR pair detects
··· HIGH 10·························· ' LED
··· GOSUB Back_Up···················· ' Back up and turn right
··· GOSUB Turn_Right
· ELSEIF (irDetectRight = 0) THEN···· ' Right IR pair detects
··· HIGH 1··························· ' LED
··· GOSUB Back_Up···················· ' Back up & turn left
··· GOSUB Turn_Left
· ELSE······························· ' Both IR pairs 1, no detects
··· GOSUB Forward_Pulse·············· ' Apply a forward pulse
· ENDIF······························ ' and check again
LOOP
'
( Subroutines )
Forward_Pulse:······················· ' Send a single forward pulse.
··· PULSOUT 13, 850
··· PULSOUT 12, 650
··· PAUSE· 20
· RETURN
Turn_Left:··························· ' Left turn, about 90-degrees.
· FOR pulseCount = 0 TO 20
··· PULSOUT 13, 650
··· PULSOUT 12, 650
··· PAUSE 20
· NEXT
· RETURN
Turn_Right:
· FOR pulseCount = 0 TO 20··········· ' Right turn, about 90-degrees.
··· PULSOUT 13, 850
··· PULSOUT 12, 850
··· PAUSE 20
· NEXT
· RETURN
Back_Up:····························· ' Back up.
· FOR pulseCount = 0 TO 40
··· PULSOUT 13, 650
··· PULSOUT 12, 850
··· PAUSE 20
· NEXT
· RETURN
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Thanks
Bill
·
I was wondering if someone could help me try to figure out some programming I am having trouble with.
·
I have the Boe-Bot kit and am trying to put it in a toy tank like vehicle. I have done that and it works great except the feature I want to add are stumping me.
·
This is what I am trying to do;
·
I am using the whiskers program (tweaked a little) I will post below. It is hunting for a path to avoid objects. When it encounters one, I would like a red LED in the barrel to flash once and then activate a separate sound board I have, and then turn as usual to avoid the object. Each time it needs to reverse to avoid the objects is when I need the led flash and the sound to go off. The sound board is from radio shack that is capable of 20 seconds of your recorded sound. I have a 3 second explosion with the led light up to simulate firing the tank. Basically the purple exposed wires are just for a switch.
·
Any help?
·
Here's the code;
' Robotics with the Boe-Bot - RoamingWithWhiskersModIRwLED.bs2
' Adapt RoamingWithWhiskers.bs2 for use with IR pairs.
' {$STAMP BS2}·················· ' Stamp directive.
' {$PBASIC 2.5}················· ' PBASIC directive.
DEBUG "Program Running!"
'
( Variables )
· irDetectLeft······ VAR· Bit
· irDetectRight····· VAR· Bit
· pulseCount········ VAR· Byte······· ' FOR...NEXT loop counter.
'
( Initialization )
FREQOUT 4, 2000, 3000················ ' Signal program start/reset
'
( Main Routine )
DO
· FREQOUT 8, 1, 38500················ ' Store IR detection values in
· irDetectLeft = IN9················· ' Bit variable
· FREQOUT 2, 1, 38500
· irDetectRight = IN0
· IF (irDetectLeft =0) AND (irDetectRight = 0) THEN
··· HIGH 10·························· ' LED
··· HIGH 1··························· ' LED
··· GOSUB Back_Up···················· ' Both IR pairs detect obsticle
··· GOSUB Turn_Left·················· ' Back up & U-turn (left twice)
··· GOSUB Turn_Left
· ELSEIF (irDetectLeft = 0) THEN····· ' Left IR pair detects
··· HIGH 10·························· ' LED
··· GOSUB Back_Up···················· ' Back up and turn right
··· GOSUB Turn_Right
· ELSEIF (irDetectRight = 0) THEN···· ' Right IR pair detects
··· HIGH 1··························· ' LED
··· GOSUB Back_Up···················· ' Back up & turn left
··· GOSUB Turn_Left
· ELSE······························· ' Both IR pairs 1, no detects
··· GOSUB Forward_Pulse·············· ' Apply a forward pulse
· ENDIF······························ ' and check again
LOOP
'
( Subroutines )
Forward_Pulse:······················· ' Send a single forward pulse.
··· PULSOUT 13, 850
··· PULSOUT 12, 650
··· PAUSE· 20
· RETURN
Turn_Left:··························· ' Left turn, about 90-degrees.
· FOR pulseCount = 0 TO 20
··· PULSOUT 13, 650
··· PULSOUT 12, 650
··· PAUSE 20
· NEXT
· RETURN
Turn_Right:
· FOR pulseCount = 0 TO 20··········· ' Right turn, about 90-degrees.
··· PULSOUT 13, 850
··· PULSOUT 12, 850
··· PAUSE 20
· NEXT
· RETURN
Back_Up:····························· ' Back up.
· FOR pulseCount = 0 TO 40
··· PULSOUT 13, 650
··· PULSOUT 12, 850
··· PAUSE 20
· NEXT
· RETURN
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Thanks
Bill
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Mike
·
Thanks for your reply and you are right once the LED lights·it never goes off! · Otherwise the movment of the vehicle is fine.
I have not yet tried to connect the sound board up, Hmm dont know were and I am very new to this. Any hints?
Thanks
Bill
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Thanks
Bill
Post Edited (Bill Kenny) : 11/22/2005 8:00:09 PM GMT
The reason the led lights never go off is because you set them to HIGH but never set them to LOW. What is missing is this:
As for the sound device, I can't help you with that.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Mike
·
THANKS!!!!!· ·
·
The LED now works. I just ran it off the 10 I/O and split the neg. to the center IR detector pins #2's.
·
Who can help me with the sound board? Like I said, all I need to do is basically find a way to have something act as a switch like touching the two purple wires together for a split second to set off the sound board.
·
Any input will be most appreciated
·
Thanks
Bill
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Thanks
Bill
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
I have these parts if they will work I dont know. NTE 54, NTE 25, NTE 13
·Thanks
·Bill
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Thanks
Bill
Post Edited (Bill Kenny) : 11/23/2005 5:07:50 PM GMT
Here is the final program;
Thanks Anyhow
Bill
' Robotics with the Boe-Bot - RoamingWithWhiskersModIRwLEDwSound.bs2
' Adapt RoamingWithWhiskers.bs2 for use with IR pairs and LED
' gun barrel with seperate sound board.
' {$STAMP BS2}·················· ' Stamp directive.
' {$PBASIC 2.5}················· ' PBASIC directive.
DEBUG "Program Running!"
'
( Variables )
· irDetectLeft······ VAR· Bit
· irDetectRight····· VAR· Bit
· pulseCount········ VAR· Byte······· ' FOR...NEXT loop counter.
'
( Initialization )
FREQOUT 4, 2000, 3000················ ' Signal program start/reset
'
( Main Routine )
DO
· FREQOUT 8, 1, 38500················ ' Store IR detection values in
· irDetectLeft = IN9················· ' Bit variable
· FREQOUT 2, 1, 38500
· irDetectRight = IN0
· IF (irDetectLeft =0) AND (irDetectRight = 0) THEN
··· HIGH 10·························· ' LED
··· PAUSE 500
··· LOW 10
··· GOSUB Back_Up···················· ' Both IR pairs detect obsticle
··· GOSUB Turn_Left·················· ' Back up & U-turn (left twice)
··· GOSUB Turn_Left
· ELSEIF (irDetectLeft = 0) THEN····· ' Left IR pair detects
··· HIGH 10·························· ' LED
··· PAUSE 500
··· LOW 10
··· GOSUB Back_Up···················· ' Back up and turn right
··· GOSUB Turn_Right
· ELSEIF (irDetectRight = 0) THEN···· ' Right IR pair detects
··· HIGH 10·························· ' LED
··· PAUSE 500
··· LOW 10
··· GOSUB Back_Up···················· ' Back up & turn left
··· GOSUB Turn_Left
· ELSE······························· ' Both IR pairs 1, no detects
··· GOSUB Forward_Pulse·············· ' Apply a forward pulse
· ENDIF······························ ' and check again
LOOP
'
( Subroutines )
Forward_Pulse:······················· ' Send a single forward pulse.
··· PULSOUT 13, 850
··· PULSOUT 12, 650
··· PAUSE· 20
· RETURN
Turn_Left:··························· ' Left turn, about 90-degrees.
· FOR pulseCount = 0 TO 20
··· PULSOUT 13, 650
··· PULSOUT 12, 650
··· PAUSE 20
· NEXT
· RETURN
Turn_Right:
· FOR pulseCount = 0 TO 20··········· ' Right turn, about 90-degrees.
··· PULSOUT 13, 850
··· PULSOUT 12, 850
··· PAUSE 20
· NEXT
· RETURN
Back_Up:····························· ' Back up.
· FOR pulseCount = 0 TO 40
··· PULSOUT 13, 650
··· PULSOUT 12, 850
··· PAUSE 20
· NEXT
· RETURN
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Thanks
Bill
Post Edited (Bill Kenny) : 11/23/2005 10:57:45 PM GMT
A suggestion. Please cease and desist from using the classic All Caps mode. It's more appropriate to the days when the computer systems didn't realize we humans spoke in upper and lower case characters. I grok that some of us do. And I'm even inclined to make allowances, but not now. Also please try to spellcheck.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Buck Rogers
www.gregg.levine.name
·· Without more information on the sound board it would be hard to make guesses, but at the very worst a small reed relay could be used to simulate a switch.· There are tons of circuits for connecting a relay to a Stamp pin, especially in Matt Gilliland's Cookbooks...The code would be much the same as your LED, except with a different pin.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
Post Edited (Chris Savage (Parallax)) : 11/24/2005 6:05:06 AM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
· -Eric