Okay just to give an idea whats on the table- I'm new I couldn't make a code without examples so I've come to ask.
The code I present here I hoped to print a reading from the temperature sensor when I press the push pin. However it doesn't work; honestly I'm surprised it doesn't have a error when I verify it. Any help would be wonderful...
int sensorPin = 0;
const int buttonPin = 2;
int buttonState = 0;
void setup()
{
pinMode(buttonPin, INPUT);
Serial.begin(9600);
}
void loop()
{
if (buttonState == HIGH) {
int reading = analogRead(sensorPin);
float voltage = reading * 5.0 / 1024;
Serial.print(voltage); Serial.println(" volts");
float temperatureC = (voltage - 0.5) * 10 ;
Serial.print(temperatureC); Serial.println(" degress C");
float temperatureF = (temperatureC * 9 / 5) + 32;
Serial.print(temperatureF); Serial.println(" degress F");
delay(1000);
}
}