Infrared Parallel Parking For SumoBot
Coding For it. ( I wrote it):
' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG "PROGRAM RUNNING!!!"
'----[I/O]----
ServoLeft PIN 13
ServoRight PIN 12
IrLedLS PIN 2
IrSenseLS PIN 1
IrLedLF PIN 4
IrSenseLF PIN 11
IrLedRF PIN 15
IrSenseRF PIN 14
IrLedRS PIN 3
IrSenseRS PIN 0
LeDSpeaker PIN 5
'----[Constants]----
IrFreq CON 18000
'----[Variables]----
counter VAR Word
FREQOUT 4,2000,3000
irBits VAR Nib
irLS VAR Bit
irRS VAR Bit
'----[initialization]----
Start_Delay:
FOR counter= 1 TO 3
PAUSE 900
FREQOUT LedSpeaker,1000,3000
NEXT
'----[Main Routine]----
DO
FREQOUT 4,2000,3000
IF (irLS = 0) AND (irRS = 0) THEN
GOSUB Forward_Pulse
ELSEIF (irLS = 1) THEN
GOSUB AnotherParking
ENDIF
LOOP
Forward_Pulse:
FOR counter=1 TO 50
PULSOUT 13,850
PULSOUT 12,650
PAUSE 20
NEXT
RETURN
AnotherParking:
FOR counter=1 TO 54
PULSOUT 13,850
PULSOUT 12,650
PAUSE 20
NEXT
FOR counter=1 TO 15
PULSOUT 13,850
PULSOUT 12,850
PAUSE 20
NEXT
PAUSE 20
FOR counter=1 TO 73
PULSOUT 13,650
PULSOUT 12,850
PAUSE 20
NEXT
FOR counter=1 TO 14
PULSOUT 13,650
PULSOUT 12,650
PAUSE 20
NEXT
FOR counter=1 TO 4
PULSOUT 13,650
PULSOUT 12,850
PAUSE 20
NEXT
RETURN
I am using a 350-00003 (infrared LEDs) and 350-00014 (infrared receiver).
I don't know why it does not work as I wanted. It is first time using Infrared as my project. All the sensor are working perfectly.
Please help me to do some amend the coding if needed. PLEASE!!
' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG "PROGRAM RUNNING!!!"
'----[I/O]----
ServoLeft PIN 13
ServoRight PIN 12
IrLedLS PIN 2
IrSenseLS PIN 1
IrLedLF PIN 4
IrSenseLF PIN 11
IrLedRF PIN 15
IrSenseRF PIN 14
IrLedRS PIN 3
IrSenseRS PIN 0
LeDSpeaker PIN 5
'----[Constants]----
IrFreq CON 18000
'----[Variables]----
counter VAR Word
FREQOUT 4,2000,3000
irBits VAR Nib
irLS VAR Bit
irRS VAR Bit
'----[initialization]----
Start_Delay:
FOR counter= 1 TO 3
PAUSE 900
FREQOUT LedSpeaker,1000,3000
NEXT
'----[Main Routine]----
DO
FREQOUT 4,2000,3000
IF (irLS = 0) AND (irRS = 0) THEN
GOSUB Forward_Pulse
ELSEIF (irLS = 1) THEN
GOSUB AnotherParking
ENDIF
LOOP
Forward_Pulse:
FOR counter=1 TO 50
PULSOUT 13,850
PULSOUT 12,650
PAUSE 20
NEXT
RETURN
AnotherParking:
FOR counter=1 TO 54
PULSOUT 13,850
PULSOUT 12,650
PAUSE 20
NEXT
FOR counter=1 TO 15
PULSOUT 13,850
PULSOUT 12,850
PAUSE 20
NEXT
PAUSE 20
FOR counter=1 TO 73
PULSOUT 13,650
PULSOUT 12,850
PAUSE 20
NEXT
FOR counter=1 TO 14
PULSOUT 13,650
PULSOUT 12,650
PAUSE 20
NEXT
FOR counter=1 TO 4
PULSOUT 13,650
PULSOUT 12,850
PAUSE 20
NEXT
RETURN
I am using a 350-00003 (infrared LEDs) and 350-00014 (infrared receiver).
I don't know why it does not work as I wanted. It is first time using Infrared as my project. All the sensor are working perfectly.
Please help me to do some amend the coding if needed. PLEASE!!
Comments
That makes it unanimous. None of us know either. We can't read your mind to know what you want, nor determine what it IS doing.
Now seriously, what is it doing wrong, very specifically?
Nuff said.
For example, someone might suggest using code tags in order to make your code more readable without realizing such action has already be suggested(and is still a good idea).
This is my sumobot picture.
If it were me, I'd use either ultrasonic (PING or HC-SR04) or Sharp IR ranging sensors. Four sensors: front, rear, and two looking at the wall to tell if you were parallel.
You've seen this? http://www.youtube.com/watch?v=LBCyhkz8S4E
PINGs (or HC-SR04) are digital and much better outdoors.
BTW, here's my Sharp IR demo as a digital sensor: