Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By carlsoncoder
#22797 I'm trying to get an RGB LED to work on the ESP8266 HUZZAH Breakout board from Adafruit, using the generic ESP8266 board from github mentioned on this site. For some reason, the analogWrite function doesn't seem to work with PWM like it did on my Arduino Uno.

I know the pins are hooked up right, since if I do "digitalWrite" to turn the individual LED's inside the RGB LED on/off, it works just fine. But when I try to use analogWrite, the RGB just stays solid white, like all the pins are set to 255. I know the RGB LED is fine too, since I hooked it up to my Arduino Uno, and it works fine as well.

This is the code that I'm using:

Code: Select allint redPin = 12;
int greenPin = 14;
int bluePin = 16;

void setup() {
  Serial.begin(115200);
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  pinMode(bluePin, OUTPUT);
  delay(10);
}

void loop() {
   analogWrite(redPin, 48);
   analogWrite(greenPin, 193);
   analogWrite(bluePin, 193);
   delay(1000);
}


I would expect this to be a reddish color - it's a common anode RGB LED so you have to do the 255 - (value) to get the value to set the pin with analogWrite, so this is actually R=207, G=62, B=62.

So I know my wiring is right, and this exact code works on an Uno. Does analogWrite just not work on the ESP8266 on this particular version of the IDE, or is there some special setup I need to do to set it up?

Any help would be appreciated!

Thanks,
Justin