fix inverted pwm

This commit is contained in:
interfisch 2019-10-10 20:20:51 +02:00
parent b4afacfa89
commit c93a8b7eab
1 changed files with 9 additions and 14 deletions

View File

@ -1,11 +1,6 @@
/* /*
* NodeMCU 1.0 (ESP-12E) * Wemos d1 mini
* Flash Size: 4M (1M SPIFFS) * 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 <Homie.h> #include <Homie.h>
@ -47,8 +42,8 @@ HomieNode lightNode("light", "light");
//(pin x) nunbering CCW starting with rst //(pin x) nunbering CCW starting with rst
#define LED_CW 14 //D5 = GPIO14 (pin5) #define LED_WW 14 //D5 = GPIO14 (pin5)
#define LED_WW 12 //D6 = GPIO12 (pin6) #define LED_CW 12 //D6 = GPIO12 (pin6)
#define BTN_A 13 //D7 = GPIO13 (pin 7) #define BTN_A 13 //D7 = GPIO13 (pin 7)
#define BTN_B 15 //D8 = GPIO15 (pin 10) #define BTN_B 15 //D8 = GPIO15 (pin 10)
@ -284,11 +279,11 @@ void loopHandler() {
if (pwmWW>PWM_MAX) { pwmWW=PWM_MAX; } //limit if (pwmWW>PWM_MAX) { pwmWW=PWM_MAX; } //limit
if (!sleep) { if (!sleep) {
analogWrite(LED_WW, pwmWW); analogWrite(LED_WW, PWM_MAX-pwmWW); //full pwm is led off
analogWrite(LED_CW, pwmCW); analogWrite(LED_CW, PWM_MAX-pwmCW); //full pwm is led off
}else{ }else{
digitalWrite(LED_WW, HIGH); //light off analogWrite(LED_WW, PWM_MAX); //light off
digitalWrite(LED_CW, HIGH); //light off analogWrite(LED_CW, PWM_MAX); //light off
} }
} }
} }
@ -318,9 +313,9 @@ void loopHandler() {
if (pwmWW>PWM_MAX) { pwmWW=PWM_MAX; } //limit if (pwmWW>PWM_MAX) { pwmWW=PWM_MAX; } //limit
if (!sleep) { if (!sleep) {
Serial.print(pwmWW); Serial.print(PWM_MAX-pwmWW);
Serial.print(", "); Serial.print(", ");
Serial.println(pwmCW); Serial.println(PWM_MAX-pwmCW);
}else{ }else{
Serial.print(0); Serial.print(0);
Serial.print(", "); Serial.print(", ");