2 * PS2 pinout cinskej kabel: data cerveny (18), clock bily (19), 5V cerny, GND zluty
8 PS2dev keyboard(19, 18); //clock, data
10 #include <LedControl.h>
12 LedControl lc=LedControl(16,14,15,2); //datain, clk, load, number of chips
13 unsigned char dispbuf[32];
19 const byte ROWS = 4; //four rows
20 const byte COLS = 3; //four columns
21 //define the cymbols on the buttons of the keypads
22 char hexaKeys[ROWS][COLS] = {
28 byte rowPins[ROWS] = {10, 9, 8, 7}; //connect to the row pinouts of the keypad
29 byte colPins[COLS] = {4, 5, 6}; //connect to the column pinouts of the keypad
31 //initialize an instance of class NewKeypad
32 Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
34 char scancodes[] = {0x45, 0x16, 0x1E, 0x26, 0x25, 0x2E, 0x36, 0x3D, 0x3E, 0x46, 0x7C, 0x7C}; //Scancodes for numbers 0-9, *, #
36 void cleardisp(char val) {
37 for(int i = 0; i<8; i++) dispbuf[i] = val;
40 void drawdisp(int shift) {
42 for(int i = 0; i<8; i++) {
43 if(shift) dispbuf[i] = dispbuf[i+1];
44 if(dispbuf[i] != '_') lc.setDigit(0,7-i,dispbuf[i],false); //addr, digit, value, decimalpoint
50 for(int i = 0; i<100; i++) {
51 analogWrite(keyledPin, i);
52 if(i >= 20*1) dispbuf[3] = dispbuf[4] = 0;
53 if(i >= 20*2) dispbuf[2] = dispbuf[5] = 0;
54 if(i >= 20*3) dispbuf[1] = dispbuf[6] = 0;
55 if(i >= 20*4) dispbuf[0] = dispbuf[7] = 0;
63 for(int i = 100; i>=0; i--) {
64 analogWrite(keyledPin, i);
65 if(i <= 20*1) dispbuf[3] = dispbuf[4] = '_';
66 if(i <= 20*2) dispbuf[2] = dispbuf[5] = '_';
67 if(i <= 20*3) dispbuf[1] = dispbuf[6] = '_';
68 if(i <= 20*4) dispbuf[0] = dispbuf[7] = '_';
77 The MAX72XX is in power-saving mode on startup,
78 we have to do a wakeup call
81 /* Set the brightness to a medium values */
82 lc.setIntensity(0,15); //0 - 15
83 /* and clear the display */
87 cleardisp('_'); drawdisp(0);
89 // send the keyboard start up
90 keyboard.keyboard_init();
96 pinMode(LED_BUILTIN, OUTPUT);
101 if(keyboard.keyboard_handle(&leds)) {
102 //Serial.print('LEDS');
103 //Serial.print(leds, HEX);
104 digitalWrite(LED_BUILTIN, leds);
107 char customKey = customKeypad.getKey();
110 Serial.println(customKey);
111 //analogWrite(keyledPin, random(0, 255));
112 analogWrite(keyledPin, 255);
113 unsigned char numkey = customKey-0x30;
116 keyboard.keyboard_mkbrk(scancodes[numkey]);
119 //lc.setDigit(0,7,numkey,false); //addr, digit, value, decimalpoint
127 if (customKey == '*') {
129 keyboard.keyboard_mkbrk(scancodes[10]);
131 //analogWrite(keyledPin, 0);
138 if (customKey == '#') {
139 keyboard.keyboard_mkbrk(0x5A); //enter