I can't figure out why the output voltage of analogWrite(255) is less than the voltage of digitalWrite(255). My code and an image of my setup are below. Some other useful information is that I am using the NodeMCU by HiLetgo, 3.3k ohm resistors with the meters, and that the meters use 1mA of current DC at full scale. Thanks for your help!
int pPressure = D2;
int pPrecipProb = D1;
int pWindSpeed = D0;
int mTemperature;
int mHumidity;
int mPressure;
int mPrecipProb;
int mWindSpeed;
int mAlert;
void setup() {
Serial.begin(9600);
pinMode(pPrecipProb, OUTPUT);
pinMode(pWindSpeed, OUTPUT);
pinMode(pPressure, OUTPUT);
pinMode(LED_BUILTIN, OUTPUT); // Initialize the LED_BUILTIN pin as an output
}
// the loop function runs over and over again forever
void loop() {
mPressure = (int) constrain(mPressure + 1, 0, 255);
mPrecipProb = (int) constrain(mPrecipProb + 1, 0, 255 );
mWindSpeed = (int) constrain(mWindSpeed + 1, 0, 255 );
if(mPressure == 255)
{
mPressure = 0;
mPrecipProb = 0;
mWindSpeed = 0;
}
digitalWrite(pPressure, HIGH );
analogWrite(pPrecipProb, 255 );
analogWrite(pWindSpeed, mWindSpeed );
delay(10);
}
Left: AnalogWrite(255)
Middle: DigitalWrite(HIGH)
Right: the other one that cycles
