2 * PS2 pinout cinskej kabel: data cerveny (18), clock bily (19), 5V cerny, GND zluty
9 PS2dev keyboard(19, 18); //clock, data
11 #include <SoftwareSerial.h>
12 //#include <NewSoftSerial.h>
13 SoftwareSerial mySerial(18, 19);
16 #include <LedControl.h>
18 LedControl lc=LedControl(16,14,15,2); //datain, clk, load, number of chips
19 unsigned char dispbuf[32];
25 const byte ROWS = 4; //four rows
26 const byte COLS = 3; //four columns
27 //define the cymbols on the buttons of the keypads
28 char hexaKeys[ROWS][COLS] = {
34 byte rowPins[ROWS] = {10, 9, 8, 7}; //connect to the row pinouts of the keypad
35 byte colPins[COLS] = {4, 5, 6}; //connect to the column pinouts of the keypad
37 //initialize an instance of class NewKeypad
38 Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
40 char scancodes[] = {0x45, 0x16, 0x1E, 0x26, 0x25, 0x2E, 0x36, 0x3D, 0x3E, 0x46, 0x7C, 0x7C}; //Scancodes for numbers 0-9, *, #
42 void cleardisp(char val) {
43 for(int i = 0; i<8; i++) dispbuf[i] = val;
46 void drawdisp(int shift) {
48 for(int i = 0; i<8; i++) {
49 if(shift) dispbuf[i] = dispbuf[i+1];
50 if(dispbuf[i] != '_') lc.setDigit(0,7-i,dispbuf[i],false); //addr, digit, value, decimalpoint
56 for(int i = 0; i<100; i++) {
57 analogWrite(keyledPin, i);
58 if(i >= 20*1) dispbuf[3] = dispbuf[4] = 0;
59 if(i >= 20*2) dispbuf[2] = dispbuf[5] = 0;
60 if(i >= 20*3) dispbuf[1] = dispbuf[6] = 0;
61 if(i >= 20*4) dispbuf[0] = dispbuf[7] = 0;
69 for(int i = 100; i>=0; i--) {
70 analogWrite(keyledPin, i);
71 if(i <= 20*1) dispbuf[3] = dispbuf[4] = '_';
72 if(i <= 20*2) dispbuf[2] = dispbuf[5] = '_';
73 if(i <= 20*3) dispbuf[1] = dispbuf[6] = '_';
74 if(i <= 20*4) dispbuf[0] = dispbuf[7] = '_';
83 The MAX72XX is in power-saving mode on startup,
84 we have to do a wakeup call
87 /* Set the brightness to a medium values */
88 lc.setIntensity(0,15); //0 - 15
89 /* and clear the display */
93 cleardisp('_'); drawdisp(0);
96 // send the keyboard start up
97 keyboard.keyboard_init();
106 pinMode(LED_BUILTIN, OUTPUT);
112 if(keyboard.keyboard_handle(&leds)) {
113 //Serial.print('LEDS');
114 //Serial.print(leds, HEX);
115 digitalWrite(LED_BUILTIN, leds);
119 char customKey = customKeypad.getKey();
122 Serial.println(customKey);
123 //analogWrite(keyledPin, random(0, 255));
124 analogWrite(keyledPin, 255);
125 unsigned char numkey = customKey-0x30;
129 keyboard.keyboard_mkbrk(scancodes[numkey]);
131 mySerial.print(customKey);
135 //lc.setDigit(0,7,numkey,false); //addr, digit, value, decimalpoint
143 if (customKey == '*') {
146 keyboard.keyboard_mkbrk(scancodes[10]);
149 //analogWrite(keyledPin, 0);
156 if (customKey == '#') {
158 keyboard.keyboard_mkbrk(0x5A); //enter