GIT.Harvie.CZ
/
mirrors
/
Programs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Thread registry is now protected by mutex
[mirrors/Programs.git]
/
arduino
/
bomba-keypad
/
bomba-keypad.ino
diff --git
a/arduino/bomba-keypad/bomba-keypad.ino
b/arduino/bomba-keypad/bomba-keypad.ino
index 3221e78022842e047d03bfaaf4863bd103269972..179d43207d4d4e4aa472c85b8b270dffd46ffb26 100644
(file)
--- a/
arduino/bomba-keypad/bomba-keypad.ino
+++ b/
arduino/bomba-keypad/bomba-keypad.ino
@@
-2,10
+2,16
@@
* PS2 pinout cinskej kabel: data cerveny (18), clock bily (19), 5V cerny, GND zluty
*/
* PS2 pinout cinskej kabel: data cerveny (18), clock bily (19), 5V cerny, GND zluty
*/
+#define SOFTSERIAL
+#ifndef SOFTSERIAL
#include <ps2dev.h>
#include <ps2dev.h>
-
PS2dev keyboard(19, 18); //clock, data
PS2dev keyboard(19, 18); //clock, data
+#else
+#include <SoftwareSerial.h>
+//#include <NewSoftSerial.h>
+SoftwareSerial mySerial(18, 19);
+#endif
#include <LedControl.h>
#include <LedControl.h>
@@
-85,9
+91,13
@@
void setup(){
intro();
cleardisp('_'); drawdisp(0);
intro();
cleardisp('_'); drawdisp(0);
-
+
+#ifndef SOFTSERIAL
// send the keyboard start up
keyboard.keyboard_init();
// send the keyboard start up
keyboard.keyboard_init();
+#else
+ mySerial.begin(4800);
+#endif
Serial.begin(9600);
Serial.begin(9600);
@@
-98,11
+108,13
@@
void setup(){
void loop(){
unsigned char leds;
void loop(){
unsigned char leds;
+#ifndef SOFTSERIAL
if(keyboard.keyboard_handle(&leds)) {
//Serial.print('LEDS');
//Serial.print(leds, HEX);
digitalWrite(LED_BUILTIN, leds);
}
if(keyboard.keyboard_handle(&leds)) {
//Serial.print('LEDS');
//Serial.print(leds, HEX);
digitalWrite(LED_BUILTIN, leds);
}
+#endif
char customKey = customKeypad.getKey();
char customKey = customKeypad.getKey();
@@
-112,8
+124,12
@@
void loop(){
analogWrite(keyledPin, 255);
unsigned char numkey = customKey-0x30;
if(numkey < 10) {
analogWrite(keyledPin, 255);
unsigned char numkey = customKey-0x30;
if(numkey < 10) {
+#ifndef SOFTSERIAL
//Send PS2
keyboard.keyboard_mkbrk(scancodes[numkey]);
//Send PS2
keyboard.keyboard_mkbrk(scancodes[numkey]);
+#else
+ mySerial.print(customKey);
+#endif
//Single digit
//lc.setDigit(0,7,numkey,false); //addr, digit, value, decimalpoint
//Single digit
//lc.setDigit(0,7,numkey,false); //addr, digit, value, decimalpoint
@@
-126,7
+142,9
@@
void loop(){
if (customKey == '*') {
//Send PS2
if (customKey == '*') {
//Send PS2
+#ifndef SOFTSERIAL
keyboard.keyboard_mkbrk(scancodes[10]);
keyboard.keyboard_mkbrk(scancodes[10]);
+#endif
//analogWrite(keyledPin, 0);
outro();
//analogWrite(keyledPin, 0);
outro();
@@
-136,6
+154,8
@@
void loop(){
}
if (customKey == '#') {
}
if (customKey == '#') {
+#ifndef SOFTSERIAL
keyboard.keyboard_mkbrk(0x5A); //enter
keyboard.keyboard_mkbrk(0x5A); //enter
+#endif
}
}
}
}
This page took
0.167266 seconds
and
4
git commands to generate.