bonjour,
je viens de me lancer dans la programmation d'un écran lcd avec interface I2c mais il sobstine a ne rien afficher.
il s'agit d'un écran 20*4
j'utilise comme programme l'exemple "Helllo Word"
//////////////////////////////////////////////début du code///////////////////////////////////////////////////////
#include <Wire.h> #include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x20,16,2); // set the LCD address to 0x20 for a 16 chars and 2 line display
void setup()
{
lcd.init(); // initialize the lcd
// Print a message to the LCD.
lcd.backlight();
lcd.print("Hello, world!");
}
void loop()
{
}
///////////////////////////////////////////////////////fin du code//////////////////////////////////////////////////
après avoir éssaillé un autre code le lcd affiche deux "0"sur latroisième ligne au gauche
////////////////////////////////////////////////début du code/////////////////////////////////////////////////////
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);
void setup()
{
lcd.init();
lcd.cursor_on();
lcd.blink_on();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("y a rien qui marche du tout ");
delay(1000);
lcd.cursor_off();
lcd.blink_off();
}
void loop()
{
}
//////////////////////////////////////////////////////////fin du code//////////////////////////////////////////////
ci joint un photo
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x20 for a 16 chars and 2 line display
void setup()
{
lcd.init(); // initialize the lcd
// Print a message to the LCD.
lcd.backlight();
lcd.print("Hello, world!");
}
void loop()
{
}
et
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);
void setup()
{
lcd.init();
lcd.cursor_on();
lcd.blink_on();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("y a rien qui marche du tout ");
delay(1000);
lcd.cursor_off();
lcd.blink_off();
}
void loop()
{
}
il s'agit d'un code qui affichent quelque chose (des "0" ou de caractères étranges ) et de l'exemple "hello word"
la lib est issue du gestionnaire des bibliothèque et j'en est pris plusieurs différentes sans jamais aucun succès
j'ai arduino 1.8.3
l'adresse I2c est:0x27 elle était donné par le fournisseur du lcd et je l'ais vérifié à l'aide d'un scanner i2c
Essaye ce code ci-dessous, il faut juste modifier la ligne lcd.begin pour mettre 20,2 car dans le code c'est pour un 4*20.
/* YourDuino.com Example Software Sketch
/
/*-----( Declare objects )-----*/
// set the LCD address to 0x27 for a 20 chars 4 line display
// Set the pins on the I2C chip used for LCD connections:
// addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address
/*-----( Declare Variables )-----*/
void setup() /*----( SETUP: RUNS ONCE )----*/
{
Serial.begin(9600); // Used to type in characters
lcd.begin(20,4); // initialize the lcd for 20 chars 4 lines, turn on backlight
// ------- Quick 3 blinks of backlight -------------
for(int i = 0; i< 3; i++)
{
lcd.backlight();
delay(250);
lcd.noBacklight();
delay(250);
}
lcd.backlight(); // finish with backlight on
//-------- Write characters on the display ------------------
// NOTE: Cursor Position: Lines and Characters start at 0
lcd.setCursor(3,0); //Start at character 4 on line 0
lcd.print("Hello, world!");
delay(1000);
lcd.setCursor(2,1);
lcd.print("From YourDuino");
delay(1000);
lcd.setCursor(0,2);
lcd.print("20 by 4 Line Display");
lcd.setCursor(0,3);
delay(2000);
lcd.print("http://YourDuino.com");
delay(8000);
// Wait and then tell user they can start the Serial Monitor and type in characters to
// Display. (Set Serial Monitor option to "No Line Ending")
lcd.setCursor(0,0); //Start at character 0 on line 0
lcd.print("Start Serial Monitor");
lcd.setCursor(0,1);
lcd.print("Type chars 2 display");
}/*--(end setup )---*/
void loop() /*----( LOOP: RUNS CONSTANTLY )----*/
{
{
// when characters arrive over the serial port...
if (Serial.available()) {
// wait a bit for the entire message to arrive
delay(100);
// clear the screen
lcd.clear();
// read all the available characters
while (Serial.available() > 0) {
// display each character to the LCD
lcd.write(Serial.read());
}
}
}
}/* --(end main loop )-- */
/* ( THE END ) */
erreur:
Arduino : 1.8.3 (Windows 10), Carte : "Arduino/Genuino Uno"
sketch_jul11a:11: error: 'POSITIVE' was not declared in this scope
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address
^
Plusieurs bibliothèque trouvées pour "Wire.h"
Utilisé : C:\Users\aurel\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.19\libraries\Wire
Non utilisé : D:\AURELIEN\Documents\Arduino\libraries\Wire
Plusieurs bibliothèque trouvées pour "LiquidCrystal_I2C.h"
Utilisé : D:\AURELIEN\Documents\Arduino\libraries\LiquidCrystal_I2C
Non utilisé : D:\AURELIEN\Documents\Arduino\libraries\arduino_257734
Non utilisé : D:\AURELIEN\Documents\Arduino\libraries\Arduino-LiquidCrystal-I2C-library-master
exit status 1
'POSITIVE' was not declared in this scope
Ce rapport pourrait être plus détaillé avec
l'option "Afficher les résultats détaillés de la compilation"
activée dans Fichier -> Préférences.
Va voir sur le lien suivant, tu auras tous les codes en fonction de la version du module I2C, perso j'ai la version 1 (voir lien ci-dessous) ,en même temps télécharge la dernière version de la Lib. LCD I2C
merci je pense aussi que j'ai la version 1.
mais ou puis-je télécharger la dernière version de la lib et surtout de quelle lib car il en existe beaucoup.
ci joint une photo de mon interface I2c.