|
815
|
Using Arduino / Programming Questions / Re: Need help with reading keyboard into an array
|
on: February 04, 2013, 08:09:30 am
|
So when you press a key, your able to see its value on the lcd? Ok, so then store it in an array, and keep storing the chars until enter is pressed. void loop() {
if (keyboard.available () > 0) { KB_chars = keyboard.read(); // new variable "KB_chars", instead of "c". Better name. if ( KB_chars != PS2_ENTER){ //If the key(s) pressed is not PS2_ENTER, then store chars in array line[count++] = KB_chars; Serial.print(line[count]); // show chars being entered. } else { // If PS2_ENTER is pressed, print them. line[count++] = '\0'; // once enter is pressed, count +1 then add zero-terminate Serial.print(line); // Not sure if it will work like this, might need to convert it to a string first. I'll double check. print array //delay(20); count = 0; // reset counter } } }
|
|
|
|
|