Arduino LCD scherm via I2C
Hier heb ik eigenlijk niets anders gedaan dan op internet kijken hoe een ander het wiel uitgevonden heeft.
Arduino analoog 4 aan SDA en Arduino analoog 5 aan SCL. VCC aan 5 Volt van Arduino, GND aan GND van Arduino.
Ik heb een LCD YwRobot Arduino lcm1602 IIC V1 2 regel display van Ebay.

Nadat je de library gevonden heb via hulpmiddelen bibliotheek beheren en in jou Arduino library geplaats heb werkt alles niet meteen.
De voorbeeld sketch kon ik niet via file voorbeelden liquidcristal_I2C openen. Via Google vond ik de sketch op https://projecthub.arduino.cc/arduino_uno_guy/i2c-liquid-crystal-displays-5eb615.
Op de site stonden geen < en > voor de libraries en de "" gaven een foutmelding.
nadat ik dat allemaal aangepast had:
/* based on Arduino_guy Lib 2019
* when copied from Arduino site there wil be errors
* hopeful here there ar no errors
* 2024
*/

;
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
//initialize the liquid crystal library
//the first parameter is the I2C address
//the second parameter is how many rows are on your screen
//the third parameter is how many columns are on your screen
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup()
{
//initialize lcd screen
lcd.init();
// turn on the backlight
lcd.backlight();
}
void loop() {
//wait for a second
delay(1000);
// tell the screen to write on the top row
// first place , first line
lcd.setCursor(0,0);
// tell the screen to write “hello, from” first place, first line
lcd.print("Hello");

;
// tell the screen to write on the bottom row
lcd.setCursor(0,1);
// tell the screen to write “Arduino” starts from the first place, seccond row
// you can change whats in the quotes to be what you want it to be!
lcd.print("Arduino");
}
//--------------------------------------------------------
Verder vond ik op:
http://www.instructables.com/id/I2C-LCD-Controller-the-easy-way/
Waar ik wel tegen opliep was dat ik verschillende liquidCrystal libs in mijn library had. Ik heb ze op 1 na allemaal verwijderd en nu werkt het goed. Lukt het niet probeer dan 1 library, start Arduino software opnieuw op
en lukt dat niet, verwijder dan de oude library en plaats een nieuwe. Start altijd na het plaatsen van een library, de Arduino ide software opnieuw op. Dus alle sketches helemaal afsluiten.
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h> // F Malpartida's NewLiquidCrystal library
#define I2C_ADDR 0x27 // Define I2C Address for controller
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
#define BACKLIGHT 3
LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
void setup()
{
lcd.begin (16,2); // initialize the lcd
// Switch on the backlight
lcd.setBacklightPin(BACKLIGHT,POSITIVE);
lcd.setBacklight(HIGH);
}
void loop()
{
// Reset the display
lcd.clear();
delay(1000);
lcd.home();
// Print on the LCD
lcd.backlight();
lcd.setCursor(0,0);
lcd.print("Hallo kijker");
lcd.setCursor(0,1);
lcd.print("naar dit scherm.");
delay(1000);
}
bron:http://think-bowl.com/arduino/controlling-an-lcd-with-an-arduino-via-i2c/