Hi all, I now have a problem trying to get my text to show the first character. For example, if i set the force as 100 it will only read 00. everything's working fine normally i would just put a space in front of my text however, i can't do it this time becsause i'm displaying a variable.
thanks #include <Wire.h>
#define LCD05 0x63 // LCD05 address
char stringBuf[20];
char stringBuf1[4];
byte buffer[4];
// constants won't change. They're used here to
// set pin numbers:
const int buttonPin1 = 11; // the number of the pushbutton pin
const int buttonPin2 = 10;
const int buttonPin3 = 9;
const int buttonPin4 = 8;
// variables will change:
int buttonState1 = 0; // variable for reading the pushbutton status
int buttonState2 = 0;
int buttonState3 = 0;
int buttonState4 = 0;
int force = 100;
void setup() {
delay(100); // Delay to wait for everything to power up
// initialize the pushbutton pin as an input:
pinMode(buttonPin1, INPUT);
pinMode(buttonPin2, INPUT);
pinMode(buttonPin3, INPUT);
pinMode(buttonPin4, 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() {
while (buttonState1 == LOW){
buttonState1 = digitalRead(buttonPin1);
buttonState2 = digitalRead(buttonPin2);
buttonState3 = digitalRead(buttonPin3);
buttonState4 = digitalRead(buttonPin4);
if (buttonState3 == HIGH){
force = force +1;
}
if (buttonState4 == HIGH){
force = force -1;
}
// if (force <= 0){
// force = 0;
//}
/*
Wire.begin();
buffer[1] = 19;
buffer[2] = 3;
buffer[3] = 3;
buffer[4] = 1;
Wire.beginTransmission(LCD05);
Wire.write(buffer,5);
Wire.endTransmission();
String message1 = " "; // 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();
*/
Wire.begin();
buffer[0] = 0;
buffer[1] = 19;
buffer[2] = 3;
buffer[3] = 3;
buffer[4] = 15;
Wire.beginTransmission(LCD05);
Wire.write(buffer,5);
Wire.endTransmission();
String displayforce = String(force); // The message to be put on the screen
int len2 = displayforce.length() + 1; // Length of the message
displayforce.toCharArray(stringBuf1, len2); // Convert the message to a car array
//itoa(force,stringBuf1,5);
// stringBuf1[0] = 0; // First byte of message to 0 (LCD05 command register)
Wire.beginTransmission(LCD05);
Wire.write(stringBuf1, len2);
Wire.endTransmission();
delay(150);
}
}