Paso 9: Código básico
AllDigital ' Todos los pines del PORTA como E/S
TRISA = 0 X 00
TRISB = 0 x 00 ' Configuro el PORTB completo como salida.
Símbolo motorpen1 = PORTA.0
Símbolo motorpen2 = PORTA.1
Símbolo motora1 = PORTB.0
Símbolo motora2 = PORTB.1
Símbolo motorb1 = PORTB.2
Símbolo motorb2 = PORTB.3
Símbolo de bobina1 = PORTB.4
Símbolo de la bobina2 = PORTB.5
Símbolo bobina3 = PORTB.6
Símbolo bobina4 = PORTB.7
PORTB = 0 X 00
PORTA = 0 X 00
Dim Sueñotiempo como Byte
Dim sleeppap como Byte
Dim cambio como poco
Dim fila como Byte
Dim fila2 como Byte
Dim fila3 como Byte
Dim fila4 como Byte
Dim fila5 como Byte
Bipo DIM como 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
Final
ecribirletra:
Si fila5.7 = True Then
GoSub bajarlapicera
Endif
GoSub moverhorizontal
Si fila5.6 = True Then
GoSub bajarlapicera
Endif
GoSub moverhorizontal
Si fila5.5 = True Then
GoSub bajarlapicera
Endif
GoSub moverhorizontal
Si fila5.4 = True Then
GoSub bajarlapicera
Endif
GoSub moverhorizontal
Si fila5.3 = True Then
GoSub bajarlapicera
Endif
GoSub moverhorizontal
Si fila5.2 = True Then
GoSub bajarlapicera
Endif
GoSub moverhorizontal
Si fila5.1 = True Then
GoSub bajarlapicera
Endif
GoSub moverhorizontal
Si fila5.0 = True Then
GoSub bajarlapicera
Endif
GoSub moverhorizontal
Si fila4.7 = True Then
GoSub bajarlapicera
Endif
GoSub moverhorizontal
Si fila4.6 = True Then
GoSub bajarlapicera
Endif
GoSub moverhorizontal
Si fila4.5 = True Then
GoSub bajarlapicera
Endif
GoSub moverhorizontal
Si fila4.4 = True Then
GoSub bajarlapicera
Endif
GoSub moverhorizontal
Si fila4.3 = True Then
GoSub bajarlapicera
Endif
GoSub moverhorizontal
Si fila4.2 = True Then
GoSub bajarlapicera
Endif
GoSub moverhorizontal
Si fila4.1 = True Then
GoSub bajarlapicera
Endif
GoSub moverhorizontal
Si fila4.0 = True Then
GoSub bajarlapicera
Endif
GoSub moverhorizontal
Si fila3.7 = True Then
GoSub bajarlapicera
Endif
GoSub moverhorizontal
Si fila3.6 = True Then
GoSub bajarlapicera
Endif
GoSub moverhorizontal
Si fila3.5 = True Then
GoSub bajarlapicera
Endif
GoSub moverhorizontal
Si fila3.4 = True Then
GoSub bajarlapicera
Endif
GoSub moverhorizontal
Si fila3.3 = True Then
GoSub bajarlapicera
Endif
GoSub moverhorizontal
Si fila3.2 = True Then
GoSub bajarlapicera
Endif
GoSub moverhorizontal
Si fila3.1 = True Then
GoSub bajarlapicera
Endif
GoSub moverhorizontal
Si fila3.0 = True Then
GoSub bajarlapicera
Endif
GoSub moverhorizontal
Si fila2.7 = True Then
GoSub bajarlapicera
Endif
GoSub moverhorizontal
Si fila2.6 = True Then
GoSub bajarlapicera
Endif
GoSub moverhorizontal
Si fila2.5 = True Then
GoSub bajarlapicera
Endif
GoSub moverhorizontal
Si fila2.4 = True Then
GoSub bajarlapicera
Endif
GoSub moverhorizontal
Si fila2.3 = True Then
GoSub bajarlapicera
Endif
GoSub moverhorizontal
Si fila2.2 = True Then
GoSub bajarlapicera
Endif
GoSub moverhorizontal
Si fila2.1 = True Then
GoSub bajarlapicera
Endif
GoSub moverhorizontal
Si fila2.0 = True Then
GoSub bajarlapicera
Endif
GoSub moverhorizontal
Si fila.7 = verdadero entonces
GoSub bajarlapicera
Endif
GoSub moverhorizontal
Si fila.6 = True Then
GoSub bajarlapicera
Endif
GoSub moverhorizontal
Si fila.5 = True Then
GoSub bajarlapicera
Endif
GoSub moverhorizontal
Si fila.4 = True Then
GoSub bajarlapicera
Endif
GoSub moverhorizontal
Si fila.3 = True Then
GoSub bajarlapicera
Endif
GoSub moverhorizontal
Si fila.2 = verdadero entonces
GoSub bajarlapicera
Endif
GoSub moverhorizontal
Si fila.1 = verdadero entonces
GoSub bajarlapicera
Endif
GoSub moverhorizontal
Si fila.0 = True Then
GoSub bajarlapicera
Endif
GoSub volvertodo
GoSub avanzarmotor1
Volver
bajarlapicera:
motorpen1 = 1
motorpen2 = 0
WaitMs 102
motorpen1 = 0
motorpen2 = 1
WaitMs 102
motorpen1 = 0
motorpen2 = 0
WaitMs 102
Volver
moverhorizontal:
Bipo = bipo + 1
Si bipo = 5 entonces 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
Volver
moverhorizontalatras:
Bipo = bipo + 1
Si bipo = 5 entonces 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
Volver
volvertodo:
Dim y As Byte
Para y = 0 a 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
Y siguiente
PORTB = 0
Volver
avanzarmotor1:
Si cambio = True Then
cambio = False
Otra cosa
cambio = True
Endif
Si cambio = True Then
PORTB = 0
bobina1 = 1
WaitMs Sueñotiempo
PORTB = 0
bobina1 = 1
bobina2 = 1
WaitMs Sueñotiempo
PORTB = 0
bobina2 = 1
WaitMs Sueñotiempo
PORTB = 0
bobina2 = 1
bobina3 = 1
WaitMs Sueñotiempo
PORTB = 0
Otra cosa
PORTB = 0
bobina3 = 1
WaitMs Sueñotiempo
PORTB = 0
bobina3 = 1
bobina4 = 1
WaitMs Sueñotiempo
PORTB = 0
bobina4 = 1
WaitMs Sueñotiempo
PORTB = 0
bobina4 = 1
bobina1 = 1
WaitMs Sueñotiempo
PORTB = 0
Endif
Volver
retrocedermotor1:
Si cambio = True Then
cambio = False
Otra cosa
cambio = True
Endif
Si cambio = True Then
PORTB = 0
bobina4 = 1
WaitMs Sueñotiempo
PORTB = 0
bobina3 = 1
bobina4 = 1
WaitMs Sueñotiempo
PORTB = 0
bobina3 = 1
WaitMs Sueñotiempo
PORTB = 0
bobina2 = 1
bobina3 = 1
WaitMs Sueñotiempo
PORTB = 0
Otra cosa
PORTB = 0
bobina2 = 1
WaitMs Sueñotiempo
PORTB = 0
bobina2 = 1
bobina1 = 1
WaitMs Sueñotiempo
PORTB = 0
bobina1 = 1
WaitMs Sueñotiempo
PORTB = 0
bobina4 = 1
bobina1 = 1
WaitMs Sueñotiempo
PORTB = 0
Endif
Volver