Étape 9: Code de base
Contenu « Todos los pins PORTA del como E/S
TRISA = 0 X 00
TRISB = 0 x 00 ' Configuro el PORTB completo como salida.
Symbole motorpen1 = PORTA.0
Symbole motorpen2 = PORTA.1
Symbole motora1 = PORTB.0
Symbole motora2 = PORTB.1
Symbole motorb1 = PORTB.2
Symbole motorb2 = PORTB.3
Symbole bobina1 = PORTB.4
Symbole bobina2 = PORTB.5
Symbole bobina3 = PORTB.6
Symbole bobina4 = PORTB.7
PORTB = 0 X 00
PORTA = 0 X 00
Dim sleeptime As Byte
Dim sleeppap As Byte
Dim cambio comme Bit
Dim fila As Byte
Dim fila2 As Byte
Dim fila3 As Byte
Dim fila4 As Byte
Dim fila5 As Byte
Dim OPBI 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
Fin
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 = True Then
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 = True Then
GoSub bajarlapicera
Endif
GoSub moverhorizontal
Si fila.1 = True Then
GoSub bajarlapicera
Endif
GoSub moverhorizontal
Si fila.0 = True Then
GoSub bajarlapicera
Endif
GoSub volvertodo
GoSub avanzarmotor1
Retour
bajarlapicera :
motorpen1 = 1
motorpen2 = 0
WaitMs 102
motorpen1 = 0
motorpen2 = 1
WaitMs 102
motorpen1 = 0
motorpen2 = 0
WaitMs 102
Retour
moverhorizontal :
bipo = bipo + 1
Si bipo = 5 alors 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
Retour
moverhorizontalatras :
bipo = bipo + 1
Si bipo = 5 alors 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
Retour
volvertodo :
Dim y As Byte
Pour 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
Prochaine y
PORTB = 0
Retour
avanzarmotor1 :
Si cambio = True Then
Cambio = False
D’autre
Cambio = True
Endif
Si 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
D’autre
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
Retour
retrocedermotor1 :
Si cambio = True Then
Cambio = False
D’autre
Cambio = True
Endif
Si 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
D’autre
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
Retour