Skrivare från en cd-läsare (9 / 11 steg)
Steg 9: Basic-kod
AllDigital "Todos los pines del PORTA como E/S
TRISA = 0X00
TRISB = 0x00 "Configuro el PORTB completo como salida.
Symbol motorpen1 = PORTA.0
Symbol motorpen2 = PORTA.1
Symbol motora1 = PORTB.0
Symbol motora2 = PORTB.1
Symbol motorb1 = PORTB.2
Symbol motorb2 = PORTB.3
Symbol bobina1 = PORTB.4
Symbol bobina2 = PORTB.5
Symbol bobina3 = PORTB.6
Symbol bobina4 = PORTB.7
PORTB = 0X00
PORTA = 0X00
Dim sleeptime som Byte
Dim sleeppap som Byte
Dim cambio som Bit
Dim fila som Byte
Dim fila2 som Byte
Dim fila3 som Byte
Dim fila4 som Byte
Dim fila5 som Byte
Dim bipo som Byte
Bipo = 1
sleeppap = 2
Fila = 255
fila2 = 255
fila3 = 255
fila4 = 255
fila5 = 255
Cambio = sant
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 domstolstvist el codigo
Fila = 0
fila2 = 0
fila3 = 0
fila4 = 0
Gå till botones
Slutet
ecribirletra:
Om fila5.7 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Om fila5.6 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Om fila5.5 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Om fila5.4 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Om fila5.3 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Om fila5.2 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Om fila5.1 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Om fila5.0 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Om fila4.7 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Om fila4.6 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Om fila4.5 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Om fila4.4 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Om fila4.3 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Om fila4.2 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Om fila4.1 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Om fila4.0 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Om fila3.7 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Om fila3.6 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Om fila3.5 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Om fila3.4 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Om fila3.3 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Om fila3.2 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Om fila3.1 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Om fila3.0 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Om fila2.7 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Om fila2.6 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Om fila2.5 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Om fila2.4 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Om fila2.3 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Om fila2.2 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Om fila2.1 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Om fila2.0 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Om fila.7 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Om fila.6 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Om fila.5 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Om fila.4 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Om fila.3 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Om fila.2 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Om fila.1 = True Then
GOSUB bajarlapicera
Endif
GOSUB moverhorizontal
Om fila.0 = True Then
GOSUB bajarlapicera
Endif
GOSUB volvertodo
GOSUB avanzarmotor1
Returnera
bajarlapicera:
motorpen1 = 1
motorpen2 = 0
WaitMs 102
motorpen1 = 0
motorpen2 = 1
WaitMs 102
motorpen1 = 0
motorpen2 = 0
WaitMs 102
Returnera
moverhorizontal:
Bipo = bipo + 1
Om bipo = 5 sedan 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
Returnera
moverhorizontalatras:
Bipo = bipo + 1
Om bipo = 5 sedan 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
Returnera
volvertodo:
Dim y som Byte
För y = 0-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
Nästa y
PORTB = 0
Returnera
avanzarmotor1:
Om cambio = sant då
Cambio = False
Annat
Cambio = sant
Endif
Om cambio = sant då
PORTB = 0
bobina1 = 1
WaitMs sömntid
PORTB = 0
bobina1 = 1
bobina2 = 1
WaitMs sömntid
PORTB = 0
bobina2 = 1
WaitMs sömntid
PORTB = 0
bobina2 = 1
bobina3 = 1
WaitMs sömntid
PORTB = 0
Annat
PORTB = 0
bobina3 = 1
WaitMs sömntid
PORTB = 0
bobina3 = 1
bobina4 = 1
WaitMs sömntid
PORTB = 0
bobina4 = 1
WaitMs sömntid
PORTB = 0
bobina4 = 1
bobina1 = 1
WaitMs sömntid
PORTB = 0
Endif
Returnera
retrocedermotor1:
Om cambio = sant då
Cambio = False
Annat
Cambio = sant
Endif
Om cambio = sant då
PORTB = 0
bobina4 = 1
WaitMs sömntid
PORTB = 0
bobina3 = 1
bobina4 = 1
WaitMs sömntid
PORTB = 0
bobina3 = 1
WaitMs sömntid
PORTB = 0
bobina2 = 1
bobina3 = 1
WaitMs sömntid
PORTB = 0
Annat
PORTB = 0
bobina2 = 1
WaitMs sömntid
PORTB = 0
bobina2 = 1
bobina1 = 1
WaitMs sömntid
PORTB = 0
bobina1 = 1
WaitMs sömntid
PORTB = 0
bobina4 = 1
bobina1 = 1
WaitMs sömntid
PORTB = 0
Endif
Returnera