Below is my code and a picture of the gibberish. It's different every time. If i pull out the temp sensor, i still get gibberish, sometimes. I'm at a loss as to what to even be looking at now. Any ideas?


// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

//set capacities
int keg1_volume = 19;
int keg2_volume = 19;
const int temperaturePin = 0;

void setup() {
  //initial delay

  //set contrast
  pinMode(9, OUTPUT);
  analogWrite(9, 100);

  // set up the LCD's number of columns and rows:
  lcd.begin(20, 4);

  // Print header to the LCD
  lcd.setCursor(6, 0);
  lcd.print("Keg (C)");
  lcd.print("Keg (F)");

  //initialize serial for debugging

  //get voltage and calculate temp
  float voltage, degreesC, degreesF;
  voltage = getVoltage(temperaturePin);
  degreesC = (voltage - 0.5) * 100.0;
  degreesF = degreesC * (9.0/5.0) + 32.0;

  //display temp


void loop() {   

float getVoltage(int pin)
  return (analogRead(pin) * 0.004882814);
  • Does problem still occur if you substitute a fixed voltage (eg use a voltage divider or pot) for the PWM'd contrast input? The PWM's sharp-cornered waveform might be introducing a lot of noise into the LCD. If fixed voltage fixes the problem, and you still want to use PWM, put a good low-pass filter between PWM and LCD pin 3 or whatever Jan 20, 2017 at 1:26
  • that was it. i had originally tried to use the pot, but couldn't get it to work (no clue why, hence using the PWM). just changed back to pot, and it's all beautiful now. thank you so much for the help!!!!
    – Charles
    Jan 20, 2017 at 5:14

1 Answer 1


Used a pot instead of the PWM from pin 9. Thanks for the help!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.