miniFloppyPINGBot

Description

The UltraSonic sensor detects something, then the bot begins to talk and sing. This same bot can be used for Collision Avoidance (minor alteration to the program), it can be a basic SumoBot (another minor alteration to the program). Here is some sample code; ; miniPINGbot1KByteDemo.bas #picaxe 28X2 ; Define the ?rocessor IC Type ; |-----| ; | _ | ; | | | |----- Signal ; | - | ; | _ |----- +5V DC ; | | | | ; | - |----- 0V/Gnd. ; | | ; |-----| symbol PING = C.5 ; convert = 3 ; Sound Travels 340279 mm/sec. so 3~=mm and 74~=inches symbol RWheel = B.0 symbol LWheel = B.1 symbol RLED = B.7 symbol GLED = B.6 symbol BLED = B.5 symbol range = b0 init: servo RWheel,145 servo LWheel,145 ; hserout pin = C.0 hsersetup B9600_8, %00000 ; 9600 baud, non-inverted polarity ; BEGIN Main Body * * * * * * * * * * * * * * * * * * * * * * * * * * * gosub red pause 500 gosub green pause 500 gosub blue pause 500 gosub Police do pulsout PING,1 pulsin PING,1,range debug range if range > 130 then gosub AllOFF if range < 100 then gosub MyName loop ; END Main Body * * * * * * * * * * * * * * * * * * * * * * * * * * * end ; BEGIN Subroutines * * * * * * * * * * * * * * * * * * * * * * * * * red: low RLED ; HIGH GLED ; HIGH BLED ; return green: HIGH RLED ; low GLED ; HIGH BLED ; return blue: HIGH RLED ; HIGH GLED ; low BLED ; return Teal: low RLED ; HIGH GLED ; low BLED ; return Orange: low RLED ; low GLED ; HIGH BLED ; return Pink: low RLED ; HIGH GLED ; low BLED ; return Police: for b3 = 0 to 4 low RLED ; HIGH GLED ; pause 50 HIGH RLED ; HIGH GLED ; HIGH BLED ; pause 50 low RLED ; HIGH GLED ; pause 50 HIGH RLED ; HIGH GLED ; HIGH BLED ; pause 150 HIGH RLED ; HIGH GLED ; low BLED ; pause 50 HIGH RLED ; HIGH GLED ; HIGH BLED ; pause 50 HIGH RLED ; HIGH GLED ; low BLED ; pause 50 HIGH RLED ; HIGH GLED ; HIGH BLED ; pause 150 next b3 return LEDOff: HIGH RLED ; HIGH GLED ; HIGH BLED ; return ALLOFF: gosub STOPP gosub red pause 500 gosub LEDOff pause 1000 gosub blue pause 500 gosub LEDOff return ; BEGIN SpeakJet Subroutines * * * * * * * * * * * * * * * * * * * * * * MyName: gosub blue ; Hello, my name is miniPINGbot ; \PITCH \240 Hello, \PITCH \250 my \PITCH \235 name \PITCH \230 is \PITCH \240 \MM \IH \PITCH \230 \NE \IY , \Stress \PE \Slow \Slow \IY \NE \GE bot hserout 0,(20, 96, 21, 114, 22, 88, 23, 5, 22, 240, 183, 7, 159, 146, 164, 2, 22, 250, 140, 155, 22, 235, 141, 154, 140, 22, 230, 8, 129, 167, 22, 240, 140, 129, 22, 230, 141, 128, 2, 14, 198, 8, 8, 128, 141, 178, 171, 8, 136, 191) ;; \PITCH \240 Hello, \PITCH \250 my \PITCH \235 name \PITCH \230 is \PITCH \240 \MM \IH \PITCH \230 \NE \IY \PE \Slow \IY \NE \GE bot ;hserout 0,(20, 96, 21, 114, 22, 255, 23, 5, 22, 240, 183, 7, 159, 146, 164, 2, 22, 250, 140, 155, 22, 235, 141, 154, 140, 22, 230, 8, 129, 167, 22, 240, 140, 129, 22, 230, 141, 128, 198, 8, 128, 141, 178, 171, 8, 136, 191) pause 2500 gosub Teal ; I am a miniFloppyBot ; \PITCH \240 I \PITCH \230 am \PITCH \240 a \PITCH \245 \MM \IH \PITCH \230 \NE \IY \PITCH \240 \FF \LE \AW \PITCH \245 \PE \IY \PITCH \230 bot hserout 0,(20, 96, 21, 114, 22, 245, 23, 5, 22, 240, 157, 22, 230, 132, 132, 140, 22, 240, 154, 128, 22, 245, 140, 129, 22, 230, 141, 128, 6, 22, 240, 186, 145, 135, 22, 245, 198, 128, 6, 22, 230, 171, 8, 136, 191) pause 2500 gosub red ; I have a RoboGuts circuit board ; \PITCH \245 I \PITCH \235 have \PITCH \230 a \PITCH \245 \RR \OW \BO \OW \PITCH \235 \GE \AW \TT \SE \PITCH \230 \SE \IH \RR \PITCH \235 \KE \EH \TT \PITCH \245 \BO \OW \RR \DE hserout 0,(20, 96, 21, 114, 22, 88, 23, 5, 22, 245, 157, 22, 235, 183, 8, 132, 166, 22, 230, 154, 128, 22, 245, 148, 137, 171, 137, 22, 235, 178, 135, 191, 187, 22, 230, 187, 129, 148, 22, 235, 194, 131, 191, 22, 245, 171, 137, 148, 174) pause 3000 gosub green ; with a PICAXE 28X2 ; \PITCH \235 with \PITCH \230 a \PITCH \240 pick \PITCH \235 ax \PITCH \245 twenty \PITCH \235 eight x two hserout 0,(20, 96, 21, 114, 22, 255, 23, 5, 22, 235, 147, 129, 8, 8, 190, 22, 230, 154, 128, 22, 240, 198, 129, 195, 22, 235, 132, 132, 196, 187, 6, 22, 245, 8, 7, 191, 7, 147, 131, 141, 7, 191, 128, 22, 235, 154, 4, 191, 131, 131, 195, 187, 8, 191, 162) pause 2500 gosub Orange ; module on it ; \PITCH \245 \MM \AW \PITCH \235 \JH \UH \LE \PITCH \230 on \PITCH \225 it hserout 0,(20, 96, 21, 114, 22, 255, 23, 5, 22, 245, 140, 135, 22, 235, 165, 138, 145, 22, 230, 136, 136, 142, 22, 225, 8, 129, 8, 191) pause 2500 gosub Pink ; The master wants me to tell a joke ; \PITCH \240 \TH \AW \PITCH \245 \MM \AY \SE \PITCH \235 \TT \RR \PITCH \230 want \SE \PITCH \235 me \PITCH \230 to tell a \Slow \JH \Slow \OW \KE hserout 0,(20, 96, 21, 114, 22, 88, 23, 5, 22, 240, 190, 135, 22, 245, 140, 132, 187, 22, 235, 191, 148, 22, 230, 6, 147, 8, 136, 142, 191, 187, 22, 235, 140, 128, 128, 22, 230, 8, 191, 162, 191, 8, 131, 8, 146, 154, 128, 8, 165, 8, 137, 194) gosub red gosub FWD pause 50 gosub STOPP pause 2500 gosub Teal ; The problem is the master ; \PITCH \235 the \PITCH \240 \PE \RR \AW \PITCH \230 \BE \LE \EH \MM \PITCH \225 is \PITCH \230 the \PITCH \235 \MM \AY \SE \PITCH \230 \TT \RR hserout 0,(20, 96, 21, 114, 22, 88, 23, 5, 22, 235, 8, 169, 8, 128, 22, 240, 198, 148, 135, 22, 230, 170, 145, 131, 140, 22, 225, 8, 129, 167, 22, 230, 8, 169, 8, 128, 22, 235, 140, 132, 187, 22, 230, 191, 148) pause 2500 gosub Orange ; cannot write a joke ; \PITCH \225 can \PITCH \235 not \PITCH \230 write \PITCH \225 a \PITCH \235 joke hserout 0,(20, 96, 21, 114, 22, 88, 23, 5, 22, 225, 194, 8, 132, 141, 22, 235, 141, 136, 191, 22, 230, 148, 155, 191, 22, 225, 154, 128, 22, 235, 7, 165, 8, 137, 197) pause 500 gosub red gosub BAK pause 50 gosub STOPP pause 250 gosub red gosub Left pause 50 gosub STOPP pause 250 gosub red gosub Right pause 50 gosub STOPP pause 250 gosub red gosub Police return end ; END SpeakJet Subroutines * * * * * * * * * * * * * * * * * * * * * * * * * * ** ; BEGIN Standard Servo Subroutines * * * * * * * * * * * * * * * * * * * * * * ; Feet BAK: servopos RWheel, 200 servopos LWheel, 100 return FWD: servopos RWheel, 100 servopos LWheel, 200 return Right: servopos RWheel, 200 servopos LWheel, 200 return Left: servopos RWheel, 100 servopos LWheel, 100 return STOPP: servopos RWheel, 145 servopos LWheel, 145 return ; END Standard Servo Subroutines * * * * * * * * * * * * * * * * * * * * * ** ; ; END Subroutines * * * * * * * * * * * * * * * * * * * * * * * * ** end
Print Page

Share

Comments

  • Login to leave a comment.