Created
February 8, 2019 20:41
-
-
Save micw/fcd2eb291dcd6db63fa2943475d47ab0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* LED PWM mit HomeWizard Funkschalter | |
* D3 - input - 433 MHZ Transmitter | |
* D7 - output Mosfet (led) | |
*/ | |
#include <smartio.h> | |
#include <smartio_homewizard.h> | |
Bus bus; | |
DimmableLed led(D7); | |
HomewizardReceiver hw(&bus,D3); | |
unsigned long num=0; | |
void setup() { | |
Serial.begin(115200); | |
analogWriteFreq(400); | |
bus.debug=true; | |
bus.on(HomewizardReceiver::TYPE_BUTTON,0xB2AFFF0E,HomewizardReceiver::ACTION_BUTTON_OFF,[]() { | |
led.set_state(0); | |
led.set_dim_value(0); | |
}); | |
// max -> 2/3 -> 1/3 -> max | |
bus.on(HomewizardReceiver::TYPE_BUTTON,0xB2AFFF0E,HomewizardReceiver::ACTION_BUTTON_ON,[]() { | |
if (led.get_state()==0 || led.get_dim_value()<=340) { | |
led.set_dim_value(1023); | |
} else if (led.get_dim_value()<=680) { | |
led.set_dim_value(340); | |
} else { | |
led.set_dim_value(680); | |
} | |
led.set_state(1); | |
}); | |
} | |
void loop() { | |
MainLoop::loop(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment