I have code that works flawlessly on the Esp8266. I recently began migrating everything to the lolin wroom d32.
Everything I have been able to successfully move and update and run without errors except for when it comes to rgb led functions
I have a 4 pin rgb originally on esp8266 I used analogWrite and had it on pins 456 Gnd
Now on the esp 32 I have it on pins 12, 13, 14, Gnd
I have tried to use ledcWrite with no success. When I do it kicks my code saying a tone of undeclared issues. I tried globals and no luck
Here is the cpp that is in my original esp8266 form. I figure it’s better to post what I knew worked before and hopefully someone can help me make the changes . I’m very green so if you can be specific with examples of what in need to change o would appreciate it
I tried just replacing analogWrite and 254 to 1023 but that didn’t work either
Esp8266 version that works correctly
// LightClass::LightClass() {
// }
void LightClass::begin() {
EEPROM.begin(14);
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
digitalWrite(redPin, HIGH);
digitalWrite(greenPin, HIGH);
digitalWrite(bluePin,
case INTERFACE_tSET3:
if (EEPROM.read(6) == 255 && EEPROM.read(7) == 255 && EEPROM.read(8) == 255) {
Serial.println(F("\n EMPTY SETTINGS ON MEMORY FOR COLOR\n"));
// int redLevel = 0;
// int greenLevel = 255;
// int blueLevel = 255;
return;
}
redLevel = EEPROM.read(6);
greenLevel = EEPROM.read(7);
blueLevel = EEPROM.read(8);
break;
}
}// END Function
case LIGHT_ACTIVATE:
if (previousActivatelTime == 0) {
Serial.println(F(" - - - > Getting in Activate Phase"));
previousActivateTime = millis();
COM.on();
on();
}
if (pattern) {
blink();
}
if (millis() - previousActivateTime > goalDelay) {
Serial.println(F(" - - - > Out of Activate Phase"));
COM.off();
off();
status = LIGHT_PAUSED;
wipeCounter();
}
break;
}
analogWrite(redPin, redTempLevel);
analogWrite(greenPin, greenTempLevel);
analogWrite(bluePin, blueTempLevel);
}
Function - Test Activate Function
*/
void LightClass::test( bool _comm ) {
if (previousTestTime == 0) {
Serial.println(F(" - - - > Getting in Test Phase"));
previousTestTime = millis();
if (_comm) {
COM.on();
}
on();
}
if (pattern) {
blink();
}
if (millis() - previousTestTime > testDelay) {
Serial.println(F(" - - - > Out of Test Phase"));
if (_comm) {
COM.off();
}
off();
status = LIGHT_PAUSED;
wipeCounter();
}
}
LightClass Lights;