projects
/
Arduino
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
be16b28
)
added 4th socket and cleanup code
author
Dobrica Pavlinusic
<dpavlin@rot13.org>
Sun, 25 Jan 2015 21:04:32 +0000
(22:04 +0100)
committer
Dobrica Pavlinusic
<dpavlin@rot13.org>
Sun, 25 Jan 2015 21:04:32 +0000
(22:04 +0100)
rpi_promini/rpi_promini.ino
patch
|
blob
|
history
diff --git
a/rpi_promini/rpi_promini.ino
b/rpi_promini/rpi_promini.ino
index
f9065f3
..
3b4fc00
100644
(file)
--- a/
rpi_promini/rpi_promini.ino
+++ b/
rpi_promini/rpi_promini.ino
@@
-146,38
+146,34
@@
void loop() {
Serial.print(serial_data[0], DEC);
Serial.print(" state: ");
Serial.println(serial_data[1] ? "on" : "off");
Serial.print(serial_data[0], DEC);
Serial.print(" state: ");
Serial.println(serial_data[1] ? "on" : "off");
- serial_pos = 0;
- if ( serial_data[1] ) { // on
- switch ( serial_data[0] ) {
+
+ byte on = serial_data[1];
+
+ // switches, 433 Mhz set of 3
+ switch ( serial_data[0] ) {
case 1:
case 1:
- mySwitch.send("110101011101010000001100");
- break;
+ on ? mySwitch.send("110101011101010000001100")
+ : mySwitch.send("110101011101010000000011");
+ break;
case 2:
case 2:
- mySwitch.send("110101010111010000001100");
+ on ? mySwitch.send("110101010111010000001100")
+ : mySwitch.send("110101010111010000000011");
break;
case 3:
break;
case 3:
- mySwitch.send("110101010101110000001100");
+ on ? mySwitch.send("110101010101110000001100")
+ : mySwitch.send("110101010101110000000011");
break;
break;
- default:
- Serial.print("invalid switch on number ");
- Serial.println(serial_data[0], DEC);
- }
- } else { // off
- switch ( serial_data[0] ) {
- case 1:
- mySwitch.send("110101011101010000000011");
- break;
- case 2:
- mySwitch.send("110101010111010000000011");
- break;
- case 3:
- mySwitch.send("110101010101110000000011");
+ case 4:
+ on ? mySwitch.send("001111110000000011000000")
+ : mySwitch.send("001111110000000000000000");
break;
default:
break;
default:
- Serial.print("invalid switch o
ff
number ");
+ Serial.print("invalid switch o
n
number ");
Serial.println(serial_data[0], DEC);
Serial.println(serial_data[0], DEC);
- }
- }
+ }
+
+ // reset for later
+ serial_pos = 0;
}
}
}
}
}
}