Skip to content

Instantly share code, notes, and snippets.

@micw
Created February 8, 2019 20:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save micw/fcd2eb291dcd6db63fa2943475d47ab0 to your computer and use it in GitHub Desktop.
Save micw/fcd2eb291dcd6db63fa2943475d47ab0 to your computer and use it in GitHub Desktop.
/**
* 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