lcd.print problem
hi all,
this first post, got arduino starter kit couple of days ago , have been working through projects. decided wanted challenge myself , came idea control servo potentiometer , have angle @ displayed on lcd.
all went breadboarding , works fine except display, have says [angle: 0] on start , increase [angle: 178] want.
but problem comes when decrease angle, keep 2 digits if has been double figures or 3 if triple.
for example; if move servo 100 0 display [angle: 027] (the last 2 digits seem random, never same)
i dont think have explained sorry.
the code have in loop is:
void loop(){
potval = analogread(potpin);
serial.print(" pot val: ");
serial.print(potval);
deg = map(potval, 0, 1023, 0, 178);
serial.print(" angle: ");
serial.print(deg);
lcd.setcursor(0, 0);
lcd.print("angle: ");
lcd.setcursor(7, 0);
lcd.print(deg);
myservo.write(deg);
delay(15);
}
this first post, got arduino starter kit couple of days ago , have been working through projects. decided wanted challenge myself , came idea control servo potentiometer , have angle @ displayed on lcd.
all went breadboarding , works fine except display, have says [angle: 0] on start , increase [angle: 178] want.
but problem comes when decrease angle, keep 2 digits if has been double figures or 3 if triple.
for example; if move servo 100 0 display [angle: 027] (the last 2 digits seem random, never same)
i dont think have explained sorry.
the code have in loop is:
void loop(){
potval = analogread(potpin);
serial.print(" pot val: ");
serial.print(potval);
deg = map(potval, 0, 1023, 0, 178);
serial.print(" angle: ");
serial.print(deg);
lcd.setcursor(0, 0);
lcd.print("angle: ");
lcd.setcursor(7, 0);
lcd.print(deg);
myservo.write(deg);
delay(15);
}
code: [select]
lcd.setcursor(7, 0);
lcd.print(deg);
lcd.print(" ");
where square brackets in examples coming ? not printed in code posted.
Arduino Forum > Using Arduino > Programming Questions > lcd.print problem
arduino
Comments
Post a Comment