Hey guys,
I've got a few different Arduino boards here but so far I've only tried this code on the Leonardo.
I'm talking to a serial-enabled LCD via SoftwareSerial. I've also got a barometer that I'm talking to over I2C with the Wire library. Everything is fine and dandy until I run into a call to Wire.begin()
. As soon as that code hits the LCD stops responding with any new text. Here's a code snippet:
#include <SoftwareSerial.h>
#include <Wire.h>
SoftwareSerial lcd(3,2);
int counter = 0;
void setup() {
lcd.begin(9600);
clear();
}
void loop() {
if (counter == 5) {
Wire.begin();
}
clear();
lcd.print(counter++);
delay(1000);
}
void clear() {
lcd.write(254);
lcd.write(128);
lcd.write(" ");
lcd.write(" ");
}
void loop() {
if (counter == 5) {
Wire.begin();
}
clear();
Serial2.print(counter++);
delay(1000);
}
void clear() {
Serial2.write(254);
Serial2.write(128);
Serial2.write(" ");
Serial2.write(" ");
}
The LCD will count up ... 0...1...2...3...4... then nothing more, just stay on 4 forever. If I comment out Wire.begin()
then everything carries on as normal. If I don't setup the serial connection to the LCD then I can read from the barometer just fine.
So it seems like there's some kind of conflict between the Wire library and SoftwareSerial. Maybe a timing issue with sending signals out at clock ticks or something? I can't image that Wire is trying to use digital pins 2 or 3 for anything...
Any help would be appreciated!
Thanks,
Rob