LCD 4bit help
first off, code, works, don't it.
the random x's in array due various characters evidently don't being between "".
and little problem, if lcd.printin print incomingbyte prints ascii code decimal (after going through itoa()), if make incomingbyte byte variable errors invalid conversion 'byte' 'char*. i'm thinking there must similar function itoa() need.
any ideas? i'm sure has extremely simple, previous question no amount of reading sparks answer.
code: [select]
#include <lcd4bit_mod.h>
lcd4bit_mod lcd = lcd4bit_mod(2);
char* ascii_chart[96] = { // lcd lib wants print in decimal i'm using character
" ", "!", "x", "#", "$", "%", "&", "x", "(", ")", "*", "+", ",", "-", ".", "/",
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ":", ";", "<", "=", ">", "?",
"@", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o",
"p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "[", "x", "x", "x", "x",
"`", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o",
"p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "{", "|", "}", "~"
};
int incomingbyte = 0;
int charconv = 0; // incomingbyte less 32 array starts @ [space]
int position = 0; // horizontal position of cursor
int line = 1; // vertical positioin of cursor
void setup(){
lcd.init();
delay(100);
lcd.clear();
serial.begin(9600);
}
void loop() {
// top left position
if (line == 2 && position == 16){
line = 1;
position = 0;
lcd.clear();}
// next line
if(line == 1 && position == 16){
line = 2;
position = 0;}
lcd.cursorto(line, position);
// send data when receive data:
if (serial.available() > 0) {
// read incoming byte:
incomingbyte = serial.read();
charconv = incomingbyte - 32;
// got:
lcd.printin(ascii_chart[charconv]);
position ++;
}
}
the random x's in array due various characters evidently don't being between "".
and little problem, if lcd.printin print incomingbyte prints ascii code decimal (after going through itoa()), if make incomingbyte byte variable errors invalid conversion 'byte' 'char*. i'm thinking there must similar function itoa() need.
any ideas? i'm sure has extremely simple, previous question no amount of reading sparks answer.

first, if want char , not char*, use '' vs. "" (single-quotes vs. double-quotes - you'll save memory =)
secondly, can't just:
lcd.print(incomingbyte);
just fine? seems you're going through lot of work print character read serial, when should able print character w/o issue. try using lcd.print() work char vs. lcd.printin() requires char*.
!c
secondly, can't just:
lcd.print(incomingbyte);
just fine? seems you're going through lot of work print character read serial, when should able print character w/o issue. try using lcd.print() work char vs. lcd.printin() requires char*.
!c
Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > LCD 4bit help
arduino
Comments
Post a Comment