Files
arduino/temp/temp.ino
2024-04-28 13:44:22 +02:00

31 lines
576 B
C++

#define TEMPPIN A1
#define LED 2
float temp;
float vout;
void setup() {
// put your setup code here, to run once:
pinMode(TEMPPIN, INPUT);
pinMode(LED, OUTPUT);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
temp = analogRead(TEMPPIN);
//temp = (temp*500)/1023.0;
//temp = (5.0*temp*100.0)/1024.0;
//temp = (temp * (5.0 / 1024.0))* 100;
temp = (5 * temp * 100.0) / 1024;
Serial.println(temp);
if(temp > 25){
digitalWrite(LED, HIGH);
}else{
digitalWrite(LED, LOW);
}
//tempc = vout;
delay(500);
}