Plusieurs informations existent sur la toile pour brancher un écran Lextronic ELCD xxxx.
Une bonne source d’information peut être le site suivant:
Prendre le temps de lire la documentation constructeur en ligne.
Produit en question : http://www.lextronic.fr/P765-afficheur-4-x-20-caracteres-retro-eclaire-bleu.html
Datasheet : http://www.lextronic.fr/~lextronic_doc/ELCD.pdf
Au niveau du branchement, la connexion entre l’écran ELCD et la carte Arduino est très simple.
1. Masse à Masse
2. Alim. +5Vc à +5Vc
3. Sortie “Rx” de l’écran ELCD à l’entrée “Tx” de la carte Arduino.
[Schéma à insérer]
Ne pas oublier de temporiser un temps soi peu les commandes série transmises à l’écran à partir de l’Arduino. Sans quoi, il y a apparition de comportements/ d’affichages étranges.
Résumé des commandes hexadécimales à transmettre à l’écran via la carte contrôleur Arduino.
Ci-dessous un exemple de code
- #include
- #include
- void setup() {
- Serial.begin(19000);
- ELCD_initialize();
- ELCD_Cursor_OFF();
- ELCD_Clear_LCD();
- ELCD_Cursor_Position(0, 0);
- ELCD_put_str("====================");
- ELCD_Cursor_Position(0, 1);
- ELCD_put_str("CAPTEUR DE NIVEAU");
- ELCD_Cursor_Position(0, 2);
- ELCD_put_str("ACTIVEE");
- ELCD_Cursor_Position(0, 3);
- ELCD_put_str("====================");
- delay(2000);
- }
- void loop() {
- // ELCD_put_str("A");
- // ELCD_put_str("B");
- int i = 10;
- char mes_i[8];
- char mes_f[80];
- while(i > 0){ // tant que la variable est inférieur à 200
- // fait quelque chose 200 fois de suite...
- ELCD_Clear_LCD();
- ELCD_Cursor_Position(0, 0);
- itoa(i,mes_i,10);
- strcpy(mes_f, " ");
- strcat(mes_f, "Time = ");
- strcat(mes_f, mes_i);
- ELCD_put_str(mes_f);
- ELCD_Cursor_OFF();
- ELCD_Cursor_Position(0, 1);
- ELCD_put_str("====================");
- ELCD_Cursor_Position(0, 2);
- itoa(2*i,mes_i,10);
- strcpy(mes_f, " ");
- strcat(mes_f, "Time = ");
- strcat(mes_f, mes_i);
- ELCD_put_str(mes_f);
- ELCD_Cursor_Position(0, 3);
- ELCD_put_str("====================");
- delay(500);
- i--; // incrémente la variable
- }
- }
- /* Initialize l'afficheur lcd */
- void ELCD_initialize(){
- Serial.print(0xA0, BYTE);
- delay(500);
- }
- /* Cache le curseur */
- void ELCD_Cursor_OFF(){
- Serial.print(0xA3, BYTE);
- Serial.print(0x0C, BYTE);
- }
- /* Affiche le curseur */
- void ELCD_Cursor_ON(){
- Serial.print(0xA3, BYTE);
- Serial.print(0x0E, BYTE);
- }
- /* Efface l'écran et place le curseur à (0, 0) */
- void ELCD_Clear_LCD(){
- Serial.print(0xA3, BYTE);
- Serial.print(0x01, BYTE);
- delay(100);
- }
- /* Place le curseur à la position (x, y) */
- void ELCD_Cursor_Position(int x, int y){
- Serial.print(0xA1, BYTE);
- Serial.print(x, BYTE);
- Serial.print(y, BYTE);
- delay(100);
- }
- /* Affiche une chaine de caractéres (char[] terminé par \0) sur l'afficheur */
- void ELCD_put_str(char *str){
- Serial.print(0xA2, BYTE);
- while(*str)
- Serial.print(*str++);
- Serial.print(0, BYTE);
- }
- /* Affiche un caratéres ASCII sur l'afficheur (caractéres spéciaux aux LCD non pris en charge) */
- void ELCD_put_chr(char ch){
- Serial.print(0xA2, BYTE);
- Serial.print(ch);
- Serial.print(0, BYTE);
- }
- /* Définit un caractére personalisé à l'index défini (de 8 à 15) suivant le tableau newChar[],
- de structure identique à celui utilisé par la fonction createChar de la lib LiquidCrystal.
- Si showAfter = 1 le caractére sera afficher aprés la création, sinon il ne sera afficher qu'aprés un ELCD_put_chr(index) */
- void ELCD_create_char(byte index, byte newChar[], byte showAfter) {
- if(showAfter)
- Serial.print(0xA4, BYTE);
- else
- Serial.print(0xA5, BYTE);
- Serial.print(index, BYTE);
- Serial.print(newChar[0] & 0x1F, BYTE);
- Serial.print(newChar[1] & 0x1F, BYTE);
- Serial.print(newChar[2] & 0x1F, BYTE);
- Serial.print(newChar[3] & 0x1F, BYTE);
- Serial.print(newChar[4] & 0x1F, BYTE);
- Serial.print(newChar[5] & 0x1F, BYTE);
- Serial.print(newChar[6] & 0x1F, BYTE);
- Serial.print(newChar[7] & 0x1F, BYTE);
- }
Aucun commentaire:
Enregistrer un commentaire