From c93a8b7eab8c6768c994b7745e10443efeea0069 Mon Sep 17 00:00:00 2001 From: Fisch Date: Thu, 10 Oct 2019 20:20:51 +0200 Subject: [PATCH] fix inverted pwm --- controllerHomie/controllerHomie.ino | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/controllerHomie/controllerHomie.ino b/controllerHomie/controllerHomie.ino index faa524f..4e54975 100644 --- a/controllerHomie/controllerHomie.ino +++ b/controllerHomie/controllerHomie.ino @@ -1,11 +1,6 @@ /* - * NodeMCU 1.0 (ESP-12E) + * Wemos d1 mini * Flash Size: 4M (1M SPIFFS) - * EN, RST -> VCC - * GPIO15 -> 10k -> GND - * GPIO0 -> Switch (Connect to Flash) -> GND - * - * Pinout: https://www.mikrocontroller-elektronik.de/wp-content/uploads/2017/02/ESP12E-Pinbelegung-1.png */ #include @@ -47,8 +42,8 @@ HomieNode lightNode("light", "light"); //(pin x) nunbering CCW starting with rst -#define LED_CW 14 //D5 = GPIO14 (pin5) -#define LED_WW 12 //D6 = GPIO12 (pin6) +#define LED_WW 14 //D5 = GPIO14 (pin5) +#define LED_CW 12 //D6 = GPIO12 (pin6) #define BTN_A 13 //D7 = GPIO13 (pin 7) #define BTN_B 15 //D8 = GPIO15 (pin 10) @@ -284,11 +279,11 @@ void loopHandler() { if (pwmWW>PWM_MAX) { pwmWW=PWM_MAX; } //limit if (!sleep) { - analogWrite(LED_WW, pwmWW); - analogWrite(LED_CW, pwmCW); + analogWrite(LED_WW, PWM_MAX-pwmWW); //full pwm is led off + analogWrite(LED_CW, PWM_MAX-pwmCW); //full pwm is led off }else{ - digitalWrite(LED_WW, HIGH); //light off - digitalWrite(LED_CW, HIGH); //light off + analogWrite(LED_WW, PWM_MAX); //light off + analogWrite(LED_CW, PWM_MAX); //light off } } } @@ -318,9 +313,9 @@ void loopHandler() { if (pwmWW>PWM_MAX) { pwmWW=PWM_MAX; } //limit if (!sleep) { - Serial.print(pwmWW); + Serial.print(PWM_MAX-pwmWW); Serial.print(", "); - Serial.println(pwmCW); + Serial.println(PWM_MAX-pwmCW); }else{ Serial.print(0); Serial.print(", ");