(If there is a solution to this already, please point me in the right direction, I don't know what to search for.)
I have an itead studio LCD shield and a LM35 temp sensor. The LCD shield has 5 buttons connected to A0 with different resistances on each button.
If I read and display the temperature(Analog pin 4), it works 100%. If I read and display the button that is pressed (Analog pin 0), it works 100%.
But as soon as I do both in the same sketch, the temp values jump around randomly and the button press affects the temp value.
What am I missing here?
sensorValue = analogRead(TEMP_ADC_PIN);
sensorValue = round((5.0 * sensorValue * 100.0)/1024.0);
maxtemp = max(maxtemp, sensorValue);
mintemp = min(mintemp, sensorValue);
output = "Max: " + String(maxtemp) + " " + "Min: " + String(mintemp);
output = String(sensorValue) + " C";
and this works:
button = ReadButtons();
lcd.print(String(button)); //Display button press in right bottom corner.
ReadButtons() I copied from this website http://www.freetronics.com/pages/16x2-lcd-shield-quickstart-guide#.UaHASbWNrg8
, but just doing a simple analogRead on pin A0 yields the same results.
Calling ReadButtons() and readTemp() in loop causes the temp values to be random and is affected by a button press.