Anthony Roggenbuck

Home Up Feedback Contents

 

Home
Up
Resume
Transcript
Projects
Work Experience
Recreation

 

 

 

 

 

 

 

 

Code for Video

' {$STAMP BS2}
' {$PBASIC 2.5}
' {$PORT COM4}


'bi - color LED - pins 14 and 15
'normally open push button - pin 8
'red LED / Buzzer on pin 12


MotorID VAR Byte ' Current Motor ID
Motor1 CON 1 ' Motor 1 control on stamp pins 1, 3 and 5
Motor2 CON 0 ' Motor 2 control on stamp pins 0, 2 and 4


counter VAR Word
pulses VAR Word
duration VAR Word

myNum VAR Word

cycles VAR Byte
pbutton VAR Byte

SRun VAR Byte
PTime VAR Byte

counter = 0
SRun =650
Ptime= 4

PAUSE 1200
DO
IF IN8=1 THEN

DEBUG HOME
DEBUG ? IN8

GOSUB gforward
PAUSE 20
GOSUB BlinkturnR
PAUSE 20
GOSUB gforward
PAUSE 20
GOSUB blinkturnR
PAUSE 10
SRun = 325
GOSUB gforward2
PAUSE 20
GOSUB blinkturnR
PAUSE 20
GOSUB gforward2
PAUSE 20
GOSUB blinkturnL
PAUSE 20
GOSUB gforward2
PAUSE 20
GOSUB blinkturnr
PAUSE 20
GOSUB gforward2
PAUSE 20
pTime=4
GOSUB Blinkturnr

FOR counter = 1 TO 50
PULSOUT 13, 900
PAUSE 80
NEXT

FOR counter = 1 TO 50
PULSOUT 13, 600
PAUSE 20
NEXT

FOR counter = 1 TO 50
PULSOUT 13, 800
PAUSE 150
NEXT

FOR counter = 1 TO 50
PULSOUT 13, 550
PAUSE 20
NEXT


GOSUB Rflash
PAUSE 50
ENDIF

LOOP

Bflash:

DO UNTIL IN8 = 1
DEBUG CR, HOME
DEBUG ? IN8
HIGH 14
LOW 15
PAUSE 300

HIGH 15
LOW 14
PAUSE 500
LOW 15

PAUSE 100
LOOP
PAUSE 3
RETURN



Rflash:
FOR cycles = 1 TO 5
DEBUG HOME
DEBUG ? cycles
HIGH 12
PAUSE 180
LOW 12
PAUSE 180

DEBUG "Brake"
MotorID = Motor1
GOSUB MotorBrake
MotorId = Motor2
GOSUB MotorBrake
PAUSE ptime

NEXT
DEBUG CLS
END
RETURN

MotorBrake:
LOW MotorID + 2
LOW MotorID + 4
HIGH MotorID
RETURN

MotorForward:
LOW MotorID + 4
HIGH MotorID + 2
HIGH MotorID
RETURN

MotorReverse:
LOW MotorID + 2
HIGH MotorID + 4
HIGH MotorID
RETURN


GForward:
FOR counter = 1 TO 15

DEBUG CR, HOME
DEBUG ? IN8

HIGH 15
LOW 14
PAUSE 10

DEBUG "F"
MotorID = Motor1
GOSUB MotorForward
MotorID = Motor2
GOSUB MotorForward
PAUSE 100
LOW 15



FOR cycles = 500 TO 1000 STEP 8
DEBUG ? cycles
PULSOUT 13, cycles
PAUSE 7
DEBUG DEC5 cycles, CR, CRSRUP
NEXT

DEBUG "pulse width increment by 20", CR
cycles = 0
FOR Cycles = 500 TO 1000 STEP 20
DEBUG ? cycles
PULSOUT 13, cycles
PAUSE 7
DEBUG DEC5 Cycles, CR, CRSRUP
NEXT
NEXT
DEBUG "Brake"
MotorID = Motor1
GOSUB MotorBrake
MotorId = Motor2
GOSUB MotorBrake
PAUSE 400
RETURN
BlinkTurnR:

FOR counter = 1 TO 5

DEBUG CR, HOME
DEBUG "TURN", CR
HIGH 14
LOW 15
PAUSE 35

HIGH 15
LOW 14
PAUSE 35
LOW 15
PAUSE 20


DEBUG "T"
MotorID = Motor1
GOSUB MotorReverse
MotorID = Motor2
GOSUB MotorForward
PAUSE 70

DEBUG "pulse width increment by 8", CR
cycles = 0
FOR cycles = 500 TO 1000 STEP 10
DEBUG ? cycles
PULSOUT 13, cycles
PAUSE 7
DEBUG DEC5 Cycles, CR, CRSRUP
NEXT

DEBUG "pulse width increment by 20", CR
cycles = 0

FOR cycles = 600 TO 900 STEP 30
DEBUG ? cycles
PULSOUT 13, cycles
PAUSE 7
DEBUG DEC5 Cycles, CR, CRSRUP
NEXT
NEXT

DEBUG "Brake"
MotorID = Motor1
GOSUB MotorBrake
MotorId = Motor2
GOSUB MotorBrake
PAUSE 200
RETURN

BlinkTurnL:

FOR counter = 1 TO 6

DEBUG CR, HOME
DEBUG "TURN", CR
HIGH 14
LOW 15
PAUSE 35

HIGH 15
LOW 14
PAUSE 35
LOW 15
PAUSE 20

DEBUG "T"
MotorID = Motor1
GOSUB Motorforward
MotorID = Motor2
GOSUB Motorreverse
PAUSE 70

NEXT

DEBUG "Brake"
MotorID = Motor1
GOSUB MotorBrake
MotorId = Motor2
GOSUB MotorBrake
PAUSE 200
RETURN

GForward2:
FOR counter = 1 TO 8

DEBUG CR, HOME
DEBUG ? IN8

HIGH 15
LOW 14
PAUSE 10

DEBUG "F"
MotorID = Motor1
GOSUB MotorForward
MotorID = Motor2
GOSUB MotorForward
PAUSE Srun
RETURN
NEXT
LOW 15

DEBUG "Brake"
MotorID = Motor1
GOSUB MotorBrake
MotorId = Motor2
GOSUB MotorBrake
PAUSE 400
RETURN

 

Send mail to with questions or comments about this web site to anthony@roggenbuck.us
Copyright 2007 Anthony Roggenbuck