Hi all,
I'm trying to figure out how to change screens/ change the text on the screen. Basically i can't use Liquid crystal because ii can't get it to connect with my LCD so I'm having to use wire.h for everything. i need to be able to press the button once and it stays on the next screen rather than having to hold it down all the time because i want it as a skip to next page kinda thing. The way the buttons are wired up is 5v one side of the button and ground with a 10k resistor is joined with digital pin 11. I can get it showing up however, both messages come up together rather than one being always on until i press the button and when I let go it goes back to a blank screen where i need it to stay on the next page.
- thanks
#include <Wire.h>
#define LCD05 0x63 // LCD05 address
char stringBuf[20];
byte buffer[4];
// constants won't change. They're used here to
// set pin numbers:
const int buttonPin = 11; // the number of the pushbutton pin
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
delay(100); // Delay to wait for everything to power up
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
Wire.begin();
buffer[0] = 0; // Clear the screen
buffer[1] = 12;
buffer[2] = 19;
buffer[3] = 31;
buffer[4] = 10;
Wire.beginTransmission(LCD05);
Wire.write(buffer,5);
Wire.endTransmission();
}
void loop() {
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed.
// if it is, the buttonState is LOW:
if (buttonState == LOW) {
digitalWrite(buttonPin, HIGH);
Wire.begin();
buffer[1] = 12;
Wire.beginTransmission(LCD05);
Wire.write(buffer,2);
Wire.endTransmission();
Wire.begin();
buffer[1] = 19;
buffer[2] = 3;
buffer[3] = 2;
buffer[4] = 3;
Wire.beginTransmission(LCD05);
Wire.write(buffer,5);
Wire.endTransmission();
delay(100);
String message1 = " {SELECT FORCE}"; // The message to be put on the screen
int len1 = message1.length() + 1; // Length of the message
message1.toCharArray(stringBuf, len1); // Convert the message to a car array
stringBuf[0] = 0; // First byte of message to 0 (LCD05 command register)
Wire.beginTransmission(LCD05);
Wire.write(stringBuf, len1);
Wire.endTransmission();
}else{
digitalWrite(buttonPin, LOW);
delay(100);
Wire.begin();
buffer[1] = 19;
buffer[2] = 3;
buffer[3] = 4;
buffer[4] = 3;
Wire.beginTransmission(LCD05);
Wire.write(buffer,5);
Wire.endTransmission();
String message2 = " {running}"; // The message to be put on the screen
int len2 = message2.length() + 1; // Length of the message
message2.toCharArray(stringBuf, len2); // Convert the message to a car array
stringBuf[0] = 0; // First byte of message to 0 (LCD05 command register)
Wire.beginTransmission(LCD05);
Wire.write(stringBuf, len2);
Wire.endTransmission();
}
}