K I am a TOTAL programming noob and i am having a hard time with this problem from my class. ANY help would be great! Here is the problem:
"Write a program with the following devices:
An active-High LED on P0 (LED1)
An active-High PB on P8 (PB1)
Servo on P13
Program the controller to loop continuously and perform the following:
- At run, the LED will be off and the servo will be fully CW.
- When the PB is pressed, the LED will blink 10 times at a rate of once per second.
- A count down will be shown on the screen.
- After the 10 blinks, the servo will move fully CCW
- When the button is released the servo will move back to CW immediately and the LED will be off.
Here is what i have so far:
' {$STAMP BS2}
' {$PBASIC 2.5}
duration VAR Word
duration = 750
DO
IF (IN8 = 1) THEN
DEBUG "10" ,CR
HIGH 0
PAUSE 500
LOW 0
PAUSE 1000
DEBUG "9" ,CR
HIGH 0
PAUSE 500
LOW 0
PAUSE 1000
DEBUG "8" ,CR
HIGH 0
PAUSE 500
LOW 0
PAUSE 1000
DEBUG "7" ,CR
HIGH 0
PAUSE 500
LOW 0
PAUSE 1000
DEBUG "6" ,CR
HIGH 0
PAUSE 500
LOW 0
PAUSE 1000
DEBUG "5" ,CR
HIGH 0
PAUSE 500
LOW 0
PAUSE 1000
DEBUG "4" ,CR
HIGH 0
PAUSE 500
LOW 0
PAUSE 1000
DEBUG "3" ,CR
HIGH 0
PAUSE 500
LOW 0
PAUSE 1000
DEBUG "2" ,CR
HIGH 0
PAUSE 500
LOW 0
PAUSE 1000
DEBUG "1" ,CR
HIGH 0
PAUSE 500
LOW 0
PAUSE 1000
IF IN8 = 1 THEN
IF duration > 500 THEN
duration = duration - 25
ENDIF
ENDIF
PULSOUT 13, duration
PAUSE 1000
ELSE
PAUSE 1000
PULSOUT 13, 500
ENDIF
LOOP
Um the LED works fine, but i can get the servo to drive correctly. Its either always energized or it wont drive all the way to ccw or cw. Thanks for your help in advance!
"Write a program with the following devices:
An active-High LED on P0 (LED1)
An active-High PB on P8 (PB1)
Servo on P13
Program the controller to loop continuously and perform the following:
- At run, the LED will be off and the servo will be fully CW.
- When the PB is pressed, the LED will blink 10 times at a rate of once per second.
- A count down will be shown on the screen.
- After the 10 blinks, the servo will move fully CCW
- When the button is released the servo will move back to CW immediately and the LED will be off.
Here is what i have so far:
' {$STAMP BS2}
' {$PBASIC 2.5}
duration VAR Word
duration = 750
DO
IF (IN8 = 1) THEN
DEBUG "10" ,CR
HIGH 0
PAUSE 500
LOW 0
PAUSE 1000
DEBUG "9" ,CR
HIGH 0
PAUSE 500
LOW 0
PAUSE 1000
DEBUG "8" ,CR
HIGH 0
PAUSE 500
LOW 0
PAUSE 1000
DEBUG "7" ,CR
HIGH 0
PAUSE 500
LOW 0
PAUSE 1000
DEBUG "6" ,CR
HIGH 0
PAUSE 500
LOW 0
PAUSE 1000
DEBUG "5" ,CR
HIGH 0
PAUSE 500
LOW 0
PAUSE 1000
DEBUG "4" ,CR
HIGH 0
PAUSE 500
LOW 0
PAUSE 1000
DEBUG "3" ,CR
HIGH 0
PAUSE 500
LOW 0
PAUSE 1000
DEBUG "2" ,CR
HIGH 0
PAUSE 500
LOW 0
PAUSE 1000
DEBUG "1" ,CR
HIGH 0
PAUSE 500
LOW 0
PAUSE 1000
IF IN8 = 1 THEN
IF duration > 500 THEN
duration = duration - 25
ENDIF
ENDIF
PULSOUT 13, duration
PAUSE 1000
ELSE
PAUSE 1000
PULSOUT 13, 500
ENDIF
LOOP
Um the LED works fine, but i can get the servo to drive correctly. Its either always energized or it wont drive all the way to ccw or cw. Thanks for your help in advance!