; 28X2+PIXYcam5-Serial.bas
; RoboGuts + PICAXE 28X2 module + SpeakJet chip + PIXY CMUcam5 + 3D Printed miniFloppyBot [URL]http://www.R2Pv1.com/[/URL]
#picaxe 28X2 ; type chip used
#terminal 9600
; Declare and Initialize Variables and Constants * * * * * * * * * * * * * * *
symbol RWheel = B.0
symbol LWheel = B.1
symbol RLED = B.7
symbol GLED = B.6
symbol BLED = B.5
; Serial IN = PIN 8 of 28X2 module to PIN 1 of PIXY CMUcam5 Grey Cable
; SerialOUT = PIN 9 of 28X2 module to PIN 4 of PIXY CMUcam5 Grey Cable
Symbol RX_PIN = C.3
Symbol RX_BAUD = T9600
; hserout pin = C.6
hsersetup B9600_8, %00000 ; 9600 baud, non-inverted polarity
init: servo RWheel,150
servo LWheel,150
symbol i = b15
; BEGIN Main Body * * * * * * * * * * * * * * *
pause 1000
gosub red
pause 1000
gosub green
pause 1000
gosub blue
pause 1000
gosub Pink
pause 1000
gosub Orange
pause 1000
gosub Teal
pause 1000
gosub LEDsOFF
gosub Cntr
gosub Speech1
Do
SerIn RX_PIN, RX_BAUD, ($AA), b1, b3,b2, b5,b4, b7,b6, b9,b8, b11,b10, b13,b12
Select Case b1
Case $55 : SerTxd( "Normal")
Case $56 : SerTxd( "Color")
Else : SerTxd( "Unknown")
End Select
SerTxd( " Checksum=" , #w1 )
SerTxd( " Signature=" , #w2 )
SerTxd( " X=" , #w3 )
SerTxd( " Y=" , #w4 )
SerTxd( " Width=" , #w5 )
SerTxd( " Height=" , #w6 )
SerTxd( CR, LF )
IF w3<90 then gosub Left
IF w3>110 then gosub Right
IF w2 = 257 then gosub RWarn
IF w2 = 258 then gosub GWarn
IF w2 = 259 then gosub BWarn
IF w2 = 260 then gosub YWarn
IF w2 = 261 then gosub PWarn
IF w2 = 262 then gosub OWarn
IF w2 = 263 then gosub PKWarn
;IF w2 = 264 then gosub Warn
;gosub Cntr
gosub Fun
;pause 1000
;gosub Learn
Loop
; BEGIN SpeakJet Talking & Singing Subroutines * * * * * * * * * * * * * * *
Vocal: ; Vocal Test, second vocal test
; \PITCH \100 \VV \OW \KE \AW \LE Test , , second , \PITCH \95 \VV \OW \KE \AW \LE \PITCH \100 test
gosub red
pause 500
gosub green
pause 500
gosub blue
pause 500
gosub Orange
gosub Cntr
hserout 0,(20, 96, 21, 114, 22, 88, 23, 5, 22, 100, 166, 137, 194, 135, 145, 191, 131, 8, 187, 191, 2, 2, 8, 187, 131, 195, 133, 141, 177, 2, 22, 95, 166, 137, 194, 135, 145, 22, 100, 191, 131, 8, 187, 191)
pause 3500
return
Speech1:
; Hello, My name is Turner
; Hello, My name is pick see Bot
gosub green
hserout 0,(20, 96, 21, 114, 22, 88, 23, 5, 183, 7, 159, 146, 164, 2, 140, 155, 141, 154, 140, 8, 129, 167, 8, 191, 151, 141, 148)
pause 3500
; I am a PIXYbot
; I am a pick see Bot
gosub Teal
hserout 0,(20, 96, 21, 114, 22, 88, 23, 5, 157, 132, 132, 140, 154, 128, 198, 129, 195, 187, 187, 128, 128, 6, 171, 8, 136, 191)
pause 3500
; I have a RoboGuts circuit board
; I have a \RR \OW \BO \OW \GE \AW \TT \Slow \SE \SE \RR \KE \EH \TT \BO \OW \RR \DE
gosub red
hserout 0,(20, 96, 21, 114, 22, 88, 23, 5, 157, 183, 8, 132, 166, 154, 128, 148, 137, 171, 137, 178, 135, 191, 8, 187, 187, 148, 194, 131, 191, 171, 137, 148, 174)
pause 3500
; I have a PICAXE 28X2 module
; I have a pick ax twenty eight X two \MM \AW \JH \UH \LE
gosub Blue
hserout 0,(20, 96, 21, 114, 22, 88, 23, 5, 157, 183, 8, 132, 166, 154, 128, 198, 129, 195, 132, 132, 196, 187, 8, 7, 191, 7, 147, 131, 141, 7, 191, 128, 154, 4, 191, 131, 131, 195, 187, 8, 191, 162, 140, 135, 165, 138, 145)
pause 4000
; I have a PIXY CMUcam5 camera
; I have a pick see C M U \KE \AY \MM five \KE \AY \MM \RR \AW
gosub Pink
hserout 0,(20, 96, 21, 114, 22, 88, 23, 5, 157, 183, 8, 132, 166, 154, 128, 198, 129, 195, 187, 187, 128, 128, 6, 187, 187, 128, 128, 6, 131, 131, 140, 6, 8, 160, 6, 194, 132, 140, 6, 186, 157, 166, 6, 194, 132, 140, 148, 135)
pause 5000
; Shall we play a game
; \PITCH \90 Shall \PITCH \95 we \PITCH \90 play \PITCH \85 a \PITCH \100 game
gosub LEDsOFF
hserout 0,(20, 96, 21, 114, 22, 88, 23, 5, 22, 90, 189, 8, 132, 8, 146, 22, 95, 147, 8, 128, 22, 90, 199, 7, 145, 131, 154, 22, 85, 154, 128, 22, 100, 8, 178, 154, 140)
pause 3500
return
Attack:
; Attack, attack, attack
; \AW \TT \AY \KE \AW \TT \AY \KE \AW \TT \AY \KE
hserout 0,(20, 96, 21, 114, 22, 88, 23, 5, 135, 191, 132, 194, 135, 191, 132, 194, 135, 191, 132, 194)
pause 2000
return
Fun:
; This is fun, give me another color
;
hserout 0,(20, 96, 21, 114, 22, 88, 23, 5, 8, 169, 8, 129, 187, 8, 129, 167, 186, 8, 134, 141, 2, 8, 178, 8, 129, 7, 166, 140, 128, 128, 134, 141, 134, 169, 151, 195, 8, 134, 146, 7, 151)
gosub Police
pause 2000
return
RWarn:
; I see red
;
gosub red
hserout 0,(20, 96, 21, 114, 22, 88, 23, 5, 157, 187, 187, 128, 128, 148, 8, 131, 176)
pause 1000
return
GWarn:
; I see green
;
gosub green
hserout 0,(20, 96, 21, 114, 22, 88, 23, 5, 157, 187, 187, 128, 128, 8, 179, 7, 148, 8, 128, 141)
pause 1000
return
BWarn:
; I see blue
;
gosub blue
hserout 0,(20, 96, 21, 114, 22, 88, 23, 5, 157, 187, 187, 128, 128, 171, 7, 146, 162)
pause 1000
return
YWarn:
; I see yellow
;
gosub Orange
hserout 0,(20, 96, 21, 114, 22, 88, 23, 5, 157, 187, 187, 128, 128, 128, 131, 146, 137)
pause 1000
return
PWarn:
; I see purple
;
gosub blue
hserout 0,(20, 96, 21, 114, 22, 88, 23, 5, 157, 187, 187, 128, 128, 199, 7, 151, 199, 8, 146)
pause 1000
return
OWarn:
; I see orange
;
gosub Orange
hserout 0,(20, 96, 21, 114, 22, 88, 23, 5, 157, 187, 187, 128, 128, 153, 141, 165)
pause 1000
return
PKWarn:
; I see pink
;
gosub Pink
hserout 0,(20, 96, 21, 114, 22, 88, 23, 5, 157, 187, 187, 128, 128, 198, 7, 128, 143, 196)
pause 1000
return
Learn: ; Learn to be a Geek
; \PITCH \100 \LE \Slow \RR \PITCH \90 \NE to \BE \IY a \PITCH \100 \GE \IY \KE
gosub blue
gosub FWD
hserout 0,(20, 96, 21, 114, 22, 88, 23, 5, 22, 100, 145, 8, 148, 22, 90, 141, 6, 8, 191, 162, 170, 128, 154, 128, 22, 100, 178, 128, 194)
pause 2000
return
; END SpeakJet Talking & Singing Subroutines * * * * * * * * * * * * * * * *
end
; BEGIN Standard Servo Subroutines * * * * * * * * * * * * * * * * * * * * * *
; PWMOUT pin, period, duty cycles
; Wheels
Cntr:
servopos RWheel, 150
servopos LWheel, 150
return
FWD:
servopos RWheel, 130
servopos LWheel, 170
return
BAK:
servopos RWheel, 165
servopos LWheel, 135
return
Right:
servopos RWheel, 125
servopos LWheel, 125
return
Left:
servopos RWheel, 175
servopos LWheel, 175
return
; END Standard Servo Subroutines * * * * * * * * * * * * * * * * * * * * * **
end
; BEGIN RGB LED subroutines * * * * * * * * * * * * * * *
LEDsOFF:
high RLED
high GLED
high BLED
return
red:
low RLED
high GLED
high BLED
return
green:
high RLED
low GLED
high BLED
return
blue:
high RLED
high GLED
low BLED
return
Pink:
low RLED
high GLED
low BLED
return
Orange:
low RLED
low GLED
high BLED
return
Teal:
high RLED
low GLED
low BLED
return
Police:
For i = 0 to 9
gosub red
pause 50
gosub LEDsOFF
gosub red
pause 50
gosub LEDsOFF
pause 100
gosub blue
pause 50
gosub LEDsOFF
gosub blue
pause 50
gosub LEDsOFF
pause 100
next i
return
; END RGB LED subroutines * * * * * * * * * * * * * * * *
end