|
voici le programme
revenir à la page précedente
' {$STAMP BS2}
' {$PBASIC 2.0}
CS CON 0
DO CON 2
Clk CON 1
vitesse VAR Byte
tension VAR Byte
INPUT 6
INPUT 7
servorotat CON 11
posrotat VAR Word
posrotat = 750
FOR B5 = 1 TO 20
PULSOUT 11,posrotat
PAUSE 17
debut:
IF IN6 = 0 THEN gauche
IF IN7 = 0 THEN droite
DEBUG CLS, DEC IN6:DEBUG DEC IN7:DEBUG DEC posrotat
GOTO suite
gauche:
posrotat = posrotat + 50
IF posrotat > 1200 THEN modifplus
GOTO rotatgauche
modifplus:
posrotat = posrotat - 50
rotatgauche:
DEBUG CLS, DEC posrotat : PAUSE 200
posrotat = posrotat -50
FOR B5 = 1 TO 50
PULSOUT 11, posrotat + B5
PAUSE 17
NEXT
posrotat = posrotat +50
GOTO suite
droite:
posrotat = posrotat - 50
IF posrotat<300 THEN modifmoins
GOTO rotatdroite
modifmoins:
posrotat = posrotat + 50
rotatdroite:
DEBUG CLS, DEC posrotat
posrotat = posrotat +50
FOR B5 = 1 TO 50
PULSOUT 11, posrotat - B5
PAUSE 17
NEXT
posrotat = posrotat -50
GOTO suite
suite:
LOW CS
SHIFTIN DO, Clk, MSBPOST, [tension\9]
HIGH CS
DEBUG CLS, DEC tension
PAUSE 500
IF tension > 100THEN troisieme
IF tension < 50 THEN premiere
GOTO seconde
premiere:
IF vitesse = 1 THEN debut
FOR B5 = 1 TO 20
PULSOUT 12, 1000
PULSOUT 10,850
PULSOUT 9,620
PAUSE 17
NEXT
FOR B5=1 TO 20
PULSOUT 8, 740
PAUSE 17
NEXT
FOR B5 = 1 TO 20
PULSOUT 12, 700
PULSOUT 10,640
PULSOUT 9,780
PAUSE 17
NEXT
vitesse = 1
GOTO debut
seconde:
IF vitesse = 2 THEN debut
FOR B5 = 1 TO 20
PULSOUT 12, 1000
PULSOUT 10,850
PULSOUT 9,620
PAUSE 17
NEXT
FOR B5=1 TO 20
PULSOUT 8, 795
PAUSE 17
NEXT
FOR B5 = 1 TO 20
PULSOUT 12, 700
PULSOUT 10,640
PULSOUT 9,780
PAUSE 17
NEXT
vitesse = 2
GOTO debut
troisieme:
IF vitesse = 3 THEN debut
FOR B5 = 1 TO 20
PULSOUT 12, 1000
PULSOUT 10,850
PULSOUT 9,620
PAUSE 17
NEXT
FOR B5=1 TO 20
PULSOUT 8, 860
PAUSE 17
NEXT
FOR B5 = 1 TO 20
PULSOUT 12, 700
PULSOUT 10,640
PULSOUT 9,780
PAUSE 17
NEXT
vitesse =3
GOTO debut
|
|