I'd like for a 16x2 LCD monitor from Sparkfun to display sensor data from a 4-directional tilt sensor from Parallax. The Arduino board is a Duemillanove. The board will run and power both programs and modules, but the serial monitor displaying the tilt sensor data will not relay the info to the LCD display. Any suggestions?
Here are the two pieces of code I am trying to get to work together—they are both from Arduino:
For the tilt:
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.print("Photo 1: ");
Serial.print(digitalRead(6), DEC); // Display Out 1 value
Serial.print("; ");
Serial.print("Photo 2: ");
Serial.println(digitalRead(7), DEC); // Display Out 2 value
delay(250); // Wiat 1/4 second
}
For the LCD:
#include <SoftwareSerial.h> // Attach the serial display's RX line to digital pin 2
SoftwareSerial mySerial(3,2); // pin 2 = TX, pin 3 = RX (unused)
void setup() {
mySerial.begin(9600); // set up serial port for 9600 baud
delay(500); // wait for display to boot up
}
void loop() {
mySerial.write(254); // move cursor to beginning of first line
mySerial.write(128);
mySerial.write(" "); // clear display
mySerial.write(" ");
mySerial.write(254); // move cursor to beginning of first line
mySerial.write(128);
mySerial.write("movement recorded");
while(1); //
wait forever
}
Update:
I'm still tinkering with the suggested program from @Ariser shown below, but keep getting a compile error:
tilt_lcd_ase.cpp: In function ‘void loop()’:
tilt_lcd_ase.cpp:24:43: error: expected ‘)’ before ‘;’ token
tilt_lcd_ase.cpp:25:43: error: expected ‘)’ before ‘;’ token
I've done some research and one person had a similar problem, but it was within #include not void loop. The search continues, but if anyone has a suggestion please chime in. The liquid crystal library is also turning up similar errors but it needs a closer look.