Stap 9: Basic-code
AllDigital ' Todos los pines del PORTA como E/S
TRISA = 0X00
TRISB = 0x00 ' Configuro el PORTB completo como salida.
Symbool van motorpen1 = PORTA.0
Symbool van motorpen2 = PORTA.1
Symbool van motora1 = PORTB.0
Symbool van motora2 = PORTB.1
Symbool van motorb1 = PORTB.2
Symbool van motorb2 = PORTB.3
Symbool van bobina1 = PORTB.4
Symbool van bobina2 = PORTB.5
Symbool van bobina3 = PORTB.6
Symbool van bobina4 = PORTB.7
PORTB = 0X00
PORTA = 0X00
Dim sleeptime As Byte
Dim sleeppap As Byte
Dim cambio als Bit
Dim fila As Byte
Dim fila2 As Byte
Dim fila3 As Byte
Dim fila4 As Byte
Dim fila5 As Byte
Dim bipo As Byte
bipo = 1
sleeppap = 2
Fila = 255
fila2 = 255
fila3 = 255
fila4 = 255
fila5 = 255
Cambio = True
Inicio:
botones:
GOSUB avanzarmotor1
GOSUB avanzarmotor1
GOSUB ecribirletra
GOSUB ecribirletra
Fila = 0
fila2 = 0
fila3 = 0
fila4 = 0
fila5 = 0
GOSUB ecribirletra
GOSUB ecribirletra
' aca empieza el codigo
' aca termina el codigo
Fila = 0
fila2 = 0
fila3 = 0
fila4 = 0
Goto botones
Einde
ecribirletra:
Als fila5.7 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Als fila5.6 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Als fila5.5 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Als fila5.4 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Als fila5.3 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Als fila5.2 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Als fila5.1 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Als fila5.0 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Als fila4.7 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Als fila4.6 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Als fila4.5 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Als fila4.4 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Als fila4.3 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Als fila4.2 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Als fila4.1 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Als fila4.0 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Als fila3.7 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Als fila3.6 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Als fila3.5 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Als fila3.4 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Als fila3.3 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Als fila3.2 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Als fila3.1 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Als fila3.0 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Als fila2.7 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Als fila2.6 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Als fila2.5 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Als fila2.4 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Als fila2.3 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Als fila2.2 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Als fila2.1 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Als fila2.0 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Als fila.7 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Als fila.6 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Als fila.5 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Als fila.4 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Als fila.3 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Als fila.2 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Als fila.1 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Als fila.0 = True Then
GOSUB bajarlapicera
Endif
GOSUB volvertodo
GOSUB avanzarmotor1
Terugkeer
bajarlapicera:
motorpen1 = 1
motorpen2 = 0
WaitMs 102
motorpen1 = 0
motorpen2 = 1
WaitMs 102
motorpen1 = 0
motorpen2 = 0
WaitMs 102
Terugkeer
moverhorizontal:
bipo = bipo + 1
Als bipo = 5 dan bipo = 1
PORTB = 0
motora1 = 1
motorb1 = 1
WaitMs sleeppap
PORTB = 0
motora1 = 1
motorb2 = 1
WaitMs sleeppap
PORTB = 0
motora2 = 1
motorb2 = 1
WaitMs sleeppap
PORTB = 0
motora2 = 1
motorb1 = 1
WaitMs sleeppap
PORTB = 0
Terugkeer
moverhorizontalatras:
bipo = bipo + 1
Als bipo = 5 dan bipo = 1
PORTB = 0
motora2 = 1
motorb1 = 1
WaitMs 6
PORTB = 0
motora2 = 1
motorb2 = 1
WaitMs 6
PORTB = 0
motora1 = 1
motorb2 = 1
WaitMs 6
PORTB = 0
motora1 = 1
motorb1 = 1
WaitMs 6
PORTB = 0
Terugkeer
volvertodo:
Dim y As Byte
Voor y = 0 tot en met 41
motora2 = 1
motorb1 = 1
WaitMs sleeppap
PORTB = 0
motora2 = 1
motorb2 = 1
WaitMs sleeppap
PORTB = 0
motora1 = 1
motorb2 = 1
WaitMs sleeppap
PORTB = 0
motora1 = 1
motorb1 = 1
WaitMs sleeppap
PORTB = 0
Volgende y
PORTB = 0
Terugkeer
avanzarmotor1:
Als cambio = True Then
Cambio = False
Anders
Cambio = True
Endif
Als cambio = True Then
PORTB = 0
bobina1 = 1
WaitMs sleeptime
PORTB = 0
bobina1 = 1
bobina2 = 1
WaitMs sleeptime
PORTB = 0
bobina2 = 1
WaitMs sleeptime
PORTB = 0
bobina2 = 1
bobina3 = 1
WaitMs sleeptime
PORTB = 0
Anders
PORTB = 0
bobina3 = 1
WaitMs sleeptime
PORTB = 0
bobina3 = 1
bobina4 = 1
WaitMs sleeptime
PORTB = 0
bobina4 = 1
WaitMs sleeptime
PORTB = 0
bobina4 = 1
bobina1 = 1
WaitMs sleeptime
PORTB = 0
Endif
Terugkeer
retrocedermotor1:
Als cambio = True Then
Cambio = False
Anders
Cambio = True
Endif
Als cambio = True Then
PORTB = 0
bobina4 = 1
WaitMs sleeptime
PORTB = 0
bobina3 = 1
bobina4 = 1
WaitMs sleeptime
PORTB = 0
bobina3 = 1
WaitMs sleeptime
PORTB = 0
bobina2 = 1
bobina3 = 1
WaitMs sleeptime
PORTB = 0
Anders
PORTB = 0
bobina2 = 1
WaitMs sleeptime
PORTB = 0
bobina2 = 1
bobina1 = 1
WaitMs sleeptime
PORTB = 0
bobina1 = 1
WaitMs sleeptime
PORTB = 0
bobina4 = 1
bobina1 = 1
WaitMs sleeptime
PORTB = 0
Endif
Terugkeer