I have a problem and I hope someone can help me here.
I am currently working on an alarm system with 2 arduinos.
The MEGA2560 is used as a control panel and a NANO as a control unit with code or RFID tag.
I let both arduinos communicate with each other via i2c, which Is working fine.
Now I have connected an LCD display (also via i2c) to the control unit (NANO) and problems occur.
At startup the display information looks good when I enter a code, but as soon as I get all kinds of vague characters on the display.
If I accelerate the speed of refreshing on the display, then I get these characters faster too. When I do not or hardly ever change, it also takes longer.
To exclude mistakes of myself, I took the example sketch of the arduino (master_writer and slave_receiver) and at the slave_receiver I added an LCD display i2c.
The same problems also here.
Is this a known problem or is it not possible to connect it at the same time?
So now I am really stuck with this project and therefore I hope someone can help me further.
Many thanks!
// Wire Slave Receiver
// by Nicholas Zambetti http://www.zambetti.com
// Demonstrates use of the Wire library
// Receives data as an I2C/TWI slave device
// Refer to the "Wire Master Writer" example for use with this
// Created 29 March 2006
// This example code is in the public domain.
#include <LiquidCrystal_I2C.h> //LCD display
#include <Wire.h>
int Test;
String Testing;
LiquidCrystal_I2C lcd(0x25, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
void setup() {
lcd.begin(16,2);
lcd.backlight();
lcd.clear();
Wire.begin(8); // join i2c bus with address #8
Wire.onReceive(receiveEvent); // register event
Serial.begin(9600); // start serial for output
}
void loop() {
delay(500);
lcd.setCursor(0, 0);
lcd.print(Testing + " " + Test);
}
// function that executes whenever data is received from master
// this function is registered as an event, see setup()
void receiveEvent(int howMany) {
while (1 < Wire.available()) { // loop through all but the last
char c = Wire.read(); // receive byte as a character
Serial.print(c); // print the character
Testing=c;
}
int x = Wire.read(); // receive byte as an integer
Serial.println(x); // print the integer
Test=x;
}