add pwmfrequency change ability, left at default 1kHz

This commit is contained in:
interfisch 2019-10-12 17:49:26 +02:00
parent 69244e8e88
commit b401a2548c
1 changed files with 3 additions and 0 deletions

View File

@ -50,12 +50,14 @@ HomieNode lightNode("light", "light");
#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)
/* /*
* VCC (pin 8) * VCC (pin 8)
* GND (pin 9) * GND (pin 9)
*/ */
#define PWM_MAX 1023 //10 bit dac #define PWM_MAX 1023 //10 bit dac
#define PWM_FREQUENCY 1000 //default: 1000 Hz
boolean sleep=true; //true turns lights off. like set_.. boolean sleep=true; //true turns lights off. like set_..
float sleep_fadevalue=0; //0=off, 1=on float sleep_fadevalue=0; //0=off, 1=on
@ -107,6 +109,7 @@ void setup() {
Serial.println("Hello"); Serial.println("Hello");
pinMode(LED_WW, OUTPUT); pinMode(LED_WW, OUTPUT);
pinMode(LED_CW, OUTPUT); pinMode(LED_CW, OUTPUT);
analogWriteFreq(PWM_FREQUENCY);
analogWrite(LED_CW, PWM_MAX); //high = off analogWrite(LED_CW, PWM_MAX); //high = off
analogWrite(LED_WW, PWM_MAX); //high = off analogWrite(LED_WW, PWM_MAX); //high = off