RC outlet switch for mbed based on: https://github.com/sui77/rc-switch
Dependencies: mbed
main.cpp@0:7d511a9bdaba, 2017-01-02 (annotated)
- Committer:
- ttajmajer
- Date:
- Mon Jan 02 13:41:03 2017 +0000
- Revision:
- 0:7d511a9bdaba
RC switch
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ttajmajer | 0:7d511a9bdaba | 1 | #include "mbed.h" |
ttajmajer | 0:7d511a9bdaba | 2 | #include "RCSwitch.h" |
ttajmajer | 0:7d511a9bdaba | 3 | |
ttajmajer | 0:7d511a9bdaba | 4 | RCSwitch sw(PC_3); |
ttajmajer | 0:7d511a9bdaba | 5 | DigitalOut led(LED1); |
ttajmajer | 0:7d511a9bdaba | 6 | |
ttajmajer | 0:7d511a9bdaba | 7 | #define SW_ADDR "11111" |
ttajmajer | 0:7d511a9bdaba | 8 | #define SW_D "00010" |
ttajmajer | 0:7d511a9bdaba | 9 | #define SW_C "00100" |
ttajmajer | 0:7d511a9bdaba | 10 | |
ttajmajer | 0:7d511a9bdaba | 11 | int main() { |
ttajmajer | 0:7d511a9bdaba | 12 | while(1){ |
ttajmajer | 0:7d511a9bdaba | 13 | wait(1); |
ttajmajer | 0:7d511a9bdaba | 14 | led = 1; |
ttajmajer | 0:7d511a9bdaba | 15 | sw.switchOn(SW_ADDR, SW_C); |
ttajmajer | 0:7d511a9bdaba | 16 | |
ttajmajer | 0:7d511a9bdaba | 17 | wait(1); |
ttajmajer | 0:7d511a9bdaba | 18 | led = 0; |
ttajmajer | 0:7d511a9bdaba | 19 | sw.switchOff(SW_ADDR, SW_C); |
ttajmajer | 0:7d511a9bdaba | 20 | |
ttajmajer | 0:7d511a9bdaba | 21 | wait(1); |
ttajmajer | 0:7d511a9bdaba | 22 | led = 1; |
ttajmajer | 0:7d511a9bdaba | 23 | sw.switchOn(SW_ADDR, SW_D); |
ttajmajer | 0:7d511a9bdaba | 24 | |
ttajmajer | 0:7d511a9bdaba | 25 | wait(1); |
ttajmajer | 0:7d511a9bdaba | 26 | led = 0; |
ttajmajer | 0:7d511a9bdaba | 27 | sw.switchOff(SW_ADDR, SW_D); |
ttajmajer | 0:7d511a9bdaba | 28 | } |
ttajmajer | 0:7d511a9bdaba | 29 | } |