Programacion de pic 16f328a
TRISA = %11111111
TRISB = %00000000
Dim iveces As Byte ’numero de veces a repetir
Dim t As Long ’tiempo de espera entre cambios
Dim prog As Long ’numero de programa a ejecutar’incializa las variables
prog = 1
t = 900
’t = 3 ’pruebas
loop:
If PORTA.0 = 0 Or PORTA.1 = 1 Then
’valida cambio de programa
If PORTA.2 = 1 Then prog = prog + 1
Ifprog > 3 Then prog = 1
’valida cambio de velocidad
If PORTA.3 = 1 Then t = t - 200
If t < 500 Then t = 900
’If PORTA.3 = 1 Then t = t - 1 ’pruebas
’If t < 1Then t = 3 ’pruebas
’inicia programa 1
If prog = 1 Then
If PORTA.0 = 0 Or PORTA.1 = 1 Then
PORTB = %01010000
WaitMs tPORTB = %01010110
WaitMs t
PORTB = %01011111
WaitMs t
PORTB = %00000000
WaitMs t
For iveces =1 To 3
PORTB = %01011111
WaitMs t
PORTB = %00000000
WaitMs t
Next iveces
EndifEndif
’inicia programa 2
If prog = 2 Then
If PORTA.0 = 0 Or PORTA.1 = 1 Then
PORTB = %00001100
WaitMs t
PORTB =%00011110
WaitMs t
PORTB = %01111110
WaitMs t
PORTB = %00000000
WaitMs t
For iveces = 1 To 3PORTB = %01111110
WaitMs t
PORTB = %00000000
WaitMs t
Next iveces
Endif
Endif’inicia programa 3
If prog = 3 Then
If PORTA.0 = 0 Or PORTA.1 = 1 Then
PORTB = %00000010
WaitMs t
PORTB = %00010110...
Regístrate para leer el documento completo.