1

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?

gibberish

// 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
 delay(1000);
 //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("BeerView");
 lcd.setCursor(0,1);
 lcd.print("Keg (C)");
 lcd.setCursor(10,1);
 lcd.print("Keg (F)");
 //initialize serial for debugging
 Serial.begin(9600);
 //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
 lcd.setCursor(0,2);
 lcd.print(degreesC);
 Serial.println(degreesC); 
 lcd.setCursor(10,2);
 lcd.print(degreesF);
 Serial.println(degreesF);
}
void loop() { 
}
float getVoltage(int pin)
{
 return (analogRead(pin) * 0.004882814);
}
asked Jan 19, 2017 at 21:54
2
  • 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 Commented 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!!!! Commented Jan 20, 2017 at 5:14

1 Answer 1

2

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

answered Jan 20, 2017 at 5:14

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.