Si además quieres enviarnos un Artículo para el Blog y redes sociales, pulsa el siguiente botón:
hola utiñizo un pic 16f873 controlo los servos q son 8 por pwm lo programo en basic para el pic simulator ide
este es el programa pero no me va funciona el primer if-else el segundo no sabe alguien pq?
AllDigital
Dim var As Byte
Dim a As Byte
Dim s02 As Byte
Dim s12 As Byte
Dim b As Byte
s02 = 90
s12 = 140
var = 2
TRISA = %11111111
TRISB = %00000000
'TRISC = %00000000
loop:
If PORTA.1 = 1 Then
For a = s12 To s02 Step -1
ServoOut PORTB.4, a
WaitMs var
Next a
For b = s12 To s02 Step -1
ServoOut PORTB.5, b
WaitMs var
Next b
For a = s02 To s12 Step 1
ServoOut PORTB.4, a
WaitMs var
Next a
For b = s02 To s12 Step 1
ServoOut PORTB.5, b
WaitMs var
Next b
'SERVOS 6,7
For a = s12 To s02 Step -1
ServoOut PORTB.6, a
WaitMs var
Next a
For b = s12 To s02 Step -1
ServoOut PORTB.7, b
WaitMs var
Next b
For a = s02 To s12 Step 1
ServoOut PORTB.6, a
WaitMs var
Next a
For b = s02 To s12 Step 1
ServoOut PORTB.7, b
WaitMs var
Next b
Goto loop
If PORTA.0 = 1 Then
'servos 0, 1, 2, 3
For a = s02 To s12 Step 1
ServoOut PORTB.0, a
WaitMs var
Next a
For b = s12 To s02 Step -1
ServoOut PORTB.1, b
WaitMs var
Next b
For a = s12 To s02 Step -1
ServoOut PORTB.0, a
WaitMs var
Next a
For b = s02 To s12 Step 1
ServoOut PORTB.1, b
WaitMs var
Next b
'servos 2, 3
For a = s02 To s12 Step 1
ServoOut PORTB.2, a
WaitMs var
Next a
For b = s12 To s02 Step -1
ServoOut PORTB.3, b
WaitMs var
Next b
For a = s12 To s02 Step -1
ServoOut PORTB.2, a
WaitMs var
Next a
For b = s02 To s12 Step 1
ServoOut PORTB.3, b
WaitMs var
Next b
Goto loop
Else
For a = s02 To s12 Step 1
ServoOut PORTB.0, a
WaitMs var
Next a
For b = s12 To s02 Step -1
ServoOut PORTB.1, b
WaitMs var
Next b
For a = s12 To s02 Step -1
ServoOut PORTB.0, a
WaitMs var
Next a
For b = s02 To s12 Step 1
ServoOut PORTB.1, b
WaitMs var
Next b
'servos 2, 3
For a = s02 To s12 Step 1
ServoOut PORTB.2, a
WaitMs var
Next a
For b = s12 To s02 Step -1
ServoOut PORTB.3, b
WaitMs var
Next b
For a = s12 To s02 Step -1
ServoOut PORTB.2, a
WaitMs var
Next a
For b = s02 To s12 Step 1
ServoOut PORTB.3, b
WaitMs var
Next b
'SERVOS 4,5
For a = s12 To s02 Step -1
ServoOut PORTB.4, a
WaitMs var
Next a
For b = s12 To s02 Step -1
ServoOut PORTB.5, b
WaitMs var
Next b
For a = s02 To s12 Step 1
ServoOut PORTB.4, a
WaitMs var
Next a
For b = s02 To s12 Step 1
ServoOut PORTB.5, b
WaitMs var
Next b
'SERVOS 6,7
For a = s12 To s02 Step -1
ServoOut PORTB.6, a
WaitMs var
Next a
For b = s12 To s02 Step -1
ServoOut PORTB.7, b
WaitMs var
Next b
For a = s02 To s12 Step 1
ServoOut PORTB.6, a
WaitMs var
Next a
For b = s02 To s12 Step 1
ServoOut PORTB.7, b
WaitMs var
Next b
Endif
Goto loop
Else
'servos 0, 1,
For a = s02 To s12 Step 1
ServoOut PORTB.0, a
WaitMs var
Next a
For b = s12 To s02 Step -1
ServoOut PORTB.1, b
WaitMs var
Next b
For a = s12 To s02 Step -1
ServoOut PORTB.0, a
WaitMs var
Next a
For b = s02 To s12 Step 1
ServoOut PORTB.1, b
WaitMs var
Next b
'servos 2, 3
For a = s02 To s12 Step 1
ServoOut PORTB.2, a
WaitMs var
Next a
For b = s12 To s02 Step -1
ServoOut PORTB.3, b
WaitMs var
Next b
For a = s12 To s02 Step -1
ServoOut PORTB.2, a
WaitMs var
Next a
For b = s02 To s12 Step 1
ServoOut PORTB.3, b
WaitMs var
Next b
'SERVOS 4,5
For a = s12 To s02 Step -1
ServoOut PORTB.4, a
WaitMs var
Next a
For b = s12 To s02 Step -1
ServoOut PORTB.5, b
WaitMs var
Next b
For a = s02 To s12 Step 1
ServoOut PORTB.4, a
WaitMs var
Next a
For b = s02 To s12 Step 1
ServoOut PORTB.5, b
WaitMs var
Next b
'SERVOS 6,7
For a = s12 To s02 Step -1
ServoOut PORTB.6, a
WaitMs var
Next a
For b = s12 To s02 Step -1
ServoOut PORTB.7, b
WaitMs var
Next b
For a = s02 To s12 Step 1
ServoOut PORTB.6, a
WaitMs var
Next a
For b = s02 To s12 Step 1
ServoOut PORTB.7, b
WaitMs var
Next b
Endif
Goto loop