huguenotte
New Member
Send from the PC via the com port lines with 16 characters visual basic 6 on a PICAXE 28x1
VOICI LE CODE PICAXE
VOICI LE CODE form1.frm
code du module 1
code visual basic 6 ZIP
VOICI LE CODE PICAXE
Code:
#picaxe 28x1
symbol Dat = b1
symbol Dat_Tmp = b2
symbol Dat1 = b3
symbol Chr = b4
symbol Chr_Tmp = b5
symbol i = b6
symbol j =b7
symbol k =b8
symbol L=b9
symbol numtext=b10
symbol counter = b11
symbol value = b12
symbol rs=4
symbol rw=2
symbol enable=1
pause 1000
'gosub LCD_Init
gosub LCD_Init
'16 caracteres
EEPROM 0,(" ") ' save values in table numtext 0
gosub Efface_Lcd
numtext=0
gosub Affiche_Text
main:
for counter = 0 to 15'
SerRxd value
write counter,value
next counter
gosub Efface_Lcd
numtext=0
gosub Affiche_Text
goto main
Efface_Lcd:
Dat=0x01
gosub LCD_Commd
return
Affiche_Text:
J=numtext: K=J+15: L=J+8
for I = J to K
If I = L Then
let Dat = 0xc0
gosub LCD_Commd
end if ' Si 8 caracteres déja envoyés pointeur mem vers
read I,Chr ' read value from table
gosub LCD_Chr
next I
' next character
return
'//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'// Initialisation de l'écran LCD (configuration LCD)
'//
'// - Ici il est important de connaître les "instructions set"
'// de votre afficheur LCD, car suivant le type d'LCD le jeu
'// de commande diffère.
'// - Ex: pour mon afficheur (PVC160101P) 1 ligne 16 caractères ci-dessous
'// - En connaissant ces caractéristiques vous pourrez adapter
'// des afficheurs LCD de différents types ou formats.
LCD_Init:
let outpins = 0x00 ' Registre DATA =0 (D0,D1...D7) à ZERO
pauseus 5000 ‘ wait 50 000us = 50 milliseconds multiples of 10 microseconds to pause
pause 300 ' On attend 16 ms pour que le LCD soit prêt
Dat=0x28 '%00101100
gosub LCD_Commd
Dat=0x0c '%00001110
gosub LCD_Commd
Dat=0x06 ',%0000110
gosub LCD_Commd
Dat=0x01
gosub LCD_Commd
return
'//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'// ENVOYER UNE COMMANDE A L'ECRAN LCD
LCD_Commd:
'Dat=b1
'Dat_Tmp=b2
Dat_Tmp = Dat And 0xF0 ' Suppression des 4 bits poids faible
gosub LCD_Enable ' Valider (E)nable LCD
Dat_Tmp= Dat and 0x0F ' Suppression des 4 bits poids fort
Dat_Tmp=Dat_Tmp*16 ' Et décalage poids faible => poids fort
gosub LCD_Enable ' Valider (E)nable LCD
' (de 40µs à 1.64ms suivant la commande (voir vos caractéristique LCD)
return
'//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'// ACTIVATION DE LA BROCHE (ENABLE) DE L'ECRAN LCD
LCD_Enable:
'let outpins =0 or enable
Dat1=Dat_Tmp
Dat1=Dat1 or enable ' Activer (E)nable LCD
let outpins = Dat1
pauseus 60' Tempo oblig pour valid Enable
Dat1=Dat1 xor enable ' Désactiver (E)nable LCD
let outpins = Dat1 ' Envoyer valeur sur registre DATA
pauseus 60
return
'//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'// ENVOYER UN CARACTERE A L'ECRAN LCD
LCD_Chr:
'Dat_Tmp = Chr_Tmp
'Dat = Chr
Chr_Tmp = Chr And 0xF0 ' Suppression des 4 bits poids faible
Chr_Tmp = Chr_Tmp or rs
Dat_Tmp = Chr_Tmp
gosub LCD_Enable ' Valider (E)nable LCD
Chr_Tmp = Chr and 0x0F ' Suppression des 4 bits poids fort
Chr_Tmp = Chr_Tmp * 16 ' Et décalage poids faible => poids fort
Chr_Tmp =Chr_Tmp or rs
Dat_Tmp = Chr_Tmp ' Valider (E)nable LCD
gosub LCD_Enable ' Valider (E)nable LCD
return
Code:
Private Sub Command1_Click()
Dim value As String
Dim texte As String
texte = Text1.Text
For i = 0 To 15
value = Mid(texte, i + 1, 1)
If value = "" Then value = " "
MSComm1.Output = value
Sleep (10)
Next
End Sub
Private Sub Form_Load()
MSComm1.Settings = "4800,N,8,1"
If MSComm1.PortOpen = True Then
MSComm1.PortOpen = False 'j’ouvre le port série
End If
'MSComm1.PortOpen = False 'je ferme le port série
MSComm1.PortOpen = True 'j’ouvre le port série
End Sub
Code:
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Integer) ' for sleep statements