BS2 with Servo rotation 90 degrees
millsir
Posts: 2
Hey guys, my friend and I are working on creating a mock train set using the standard servo as the gate. We are having trouble with the code and making the servo rotate only 90 degrees when BS2 reads 0 and then rotate when it reads 1. We are using a photo eye to change the output. Can anyone please help us with the code we need.
Thanks in advance
Thanks in advance
Comments
http://www.youtube.com/watch?v=E856jJRtF2s
' {$STAMP BS2}
' {$PBASIC 2.5}
OUTPUT 4
OUTPUT 8
INPUT 0
Servo_pin CON 14
Temp VAR Word
reblink:
DEBUG DEC IN0
IF IN8 = 1 THEN GOTO reblink
IF IN8 = 0 THEN GOTO start
start:
FOR temp = 000 TO 650
45 deg, PULSOUT Servo_pin,temp
PAUSE 20
NEXT
FOR temp = 650 TO 000
45 deg, PULSOUT Servo_pin,temp
PAUSE 20
NEXT
OUT4=1
PAUSE 1000
OUT4=0
OUT8=1
PAUSE 1000
OUT8=0
GOTO reblink
We are also stuck on changing the speed and the start orientation
That video is short, but there's more information presented than meets the casual eye.
Maybe someone will come along and write your code for you, I want to help you learn. I'm very mean that way.
'
Take a look @ Exp. #26 in StampWorks
'
http://www.parallax.com/Portals/0/Downloads/docs/books/sw/Web-SW-v2.1.pdf
'
google is you friend.