this program is based on the PS/2 keyboard library and the LCD library, the lcd display whatever input is coming from the PS/2 keyboard.
Diff: main.cpp
- Revision:
- 0:3774ff2f9a59
- Child:
- 1:2178724f96f1
diff -r 000000000000 -r 3774ff2f9a59 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sun Jan 30 15:05:39 2011 +0000 @@ -0,0 +1,57 @@ +/* This is my first project with the mbed. I have just collected libraries together + and came up with the mash up below. The keyboard input is received by both the + terminal and the LCD connected to the mbed. + the PS/2 wiring is as follows + ====p22 clock, white=========== + ====p21 signal, green========== + ====yellow, orange +/- voltage= +*/ +#include "mbed.h" +#include "PS2ASCII.h" +#include "TextLCD.h" + +TextLCD lcd(p15, p16, p17, p18, p19, p20); // rs, e, d4-d7 +PS2ASCII myKeyboard(p22, p21); +DigitalOut mLED(LED1); +DigitalOut mLED2(LED2);// not needed for now + int i=0; + char *buffer; +int main() { + printf("the program has started"); + printf("=========================================\n "); + while (1) { + unsigned char symbol = myKeyboard.getChar(); + if (myKeyboard.E0flag() == true) { //is the make code one or two bytes long? + printf(" E0 "); + mLED2=1; + } else { + wait(0.2); + printf("%c", symbol); + lcd.locate(0,0); + lcd.printf("Keyboard: \n"); + + if (symbol) { + + i++; + buffer = new char[16]; //create a char array to hold 16 char + buffer[i]= symbol; //traverse the array one step at a time + //lcd.cls(); + lcd.locate(i,1); + lcd.printf("%c", buffer[i]); //print the char array + printf(" \t"); + //wait(0.9); + if (i==16) { + lcd.cls(); + i=0; + delete [] buffer; + +x + } + //anytime a key is pressed one of LEDs light up + mLED=1; + wait(0.04); + mLED=0; + } + } + } +} \ No newline at end of file