SHARE
TWEET

arduiGno lamP

a guest Jan 21st, 2020 77 in 338 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. float temp(){
  2.   float result;
  3.   float valore;
  4.   valore=analogRead(0);
  5.   result=valore*0.323-273;
  6.   return result;
  7.   }
  8.  
  9. void setup() {
  10.   // put your setup code here, to run once:
  11.   pinMode(2,OUTPUT);  // lampada gialla
  12.   pinMode(4,OUTPUT);  // lampada verde
  13.   pinMode(5,OUTPUT);  // lampada rossa
  14.   Serial.begin(9600);  
  15.   analogReference(EXTERNAL);
  16. }
  17.  
  18. void loop() {
  19.   // put your main code here, to run repeatedly:
  20.   Serial.print(" La temperatura misurata รจ ");
  21.   Serial.print(temp());
  22.   Serial.println(" gradi centigradi ");
  23.   delay(500);
  24.   //lampada rossa
  25.   if (temp()> 20 && temp()<23) {
  26.     digitalWrite(5,HIGH);
  27.     }
  28.     else{
  29.       digitalWrite(5,LOW);
  30.     };
  31.   //lampada gialla
  32.   if (temp()> 23 && temp()<25) {
  33.     digitalWrite(2,HIGH);
  34.     }
  35.     else{
  36.       digitalWrite(2,LOW);
  37.     };
  38.     //lampada verde
  39.    if (temp()> 25 && temp()<27) {
  40.     digitalWrite(4,HIGH);
  41.     }
  42.     else{
  43.       digitalWrite(4,LOW);
  44.     };  
  45. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top