LCD + Seeestudio mega: analog pin contrast ctrl?


I am using a Seeestudio mega with the following code:

int ledPin = 13;   
void setup()
 analogWrite(5, 0);

pinMode(ledPin, OUTPUT);     

void loop()
  digitalWrite(ledPin, HIGH);   // sets the LED on
  delay(1000);                  // waits for a second
  digitalWrite(ledPin, LOW);    // sets the LED off
  delay(1000);                  // waits for a second  

I am seeing ~0.8V at the pin. What value should I mesure at that pin 5 of the mega? 0V?

I am trying to control the contrast of an LCD directly (without a resistor or a pot) using analog pin 5 with no success. I dont get what I am doing wrong.


It’s not clear from your post, but it sounds like you are trying to use an analog pin for pwm. Try the pin 5 in the pwm section. It can be confusing because of the terms used, but the analog pins are actually inputs.

When you analogWrite to pin 5 its going to the PWM pin 5. The PWM pins are digital IO pins but they use Pulse Width Modulation to simulate an analog output. This will explain it better then i can.