int alarma = 7;
char estado;
void setup(){
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(alarma, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
byte sensorValue = analogRead(A0);
// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):K
float voltage = (sensorValue * 5.0) / 1023 ;
float temp = (voltage - 0.4)*51.28 ;
// print out the value you read:
Serial.print(temp);
Serial.print(" C");
Serial.print("|");
delay (3000);
if (Serial.available()){
estado = Serial.read();
if (estado == 'A'){
digitalWrite (alarma, HIGH);
delay (2000);
}
if (estado == 'B'){
digitalWrite (alarma, LOW);
delay (2000);
}
}
}
Comments