ESP32_AnalogWrite
ESP32_AnalogWrite copied to clipboard
Not outputting correct voltage
#include <Arduino.h>
#include <analogWrite.h>
int brightStep = 1;
int brightness = 0;
uint8_t ledR = 34;
uint8_t ledG = 35;
uint8_t ledB = 32;
uint8_t ledW = 33;
void setup()
{
// Set resolution for a specific pin
analogWriteResolution(ledR, 12);
analogWriteResolution(ledG, 12);
analogWriteResolution(ledB, 12);
analogWriteResolution(ledW, 12);
analogWrite(ledR, 255);
analogWrite(ledG, 255);
analogWrite(ledB, 255);
analogWrite(ledW, 255);
}
void loop() {}
This outputs ledR = 0 = GPIO34 ledG = 0 = GPIO35 ledB = 1.6 V = GPIO32 ledW = 1.6 V = GPIO33
Why?
So pins 34, 35, 36, 39 are input only. That does not explain why the other pins only output a maximum of 1.65 V...
If you are measuring PWM with a standard VOM this would be normal. The duty cycle will throw off a conventional VOM. Set a pin HIGH and measure the voltage. If it's still just 1.65V then that would be an issue.