ARDUINO BASED WEATHER MONITORING DEVICE FOR HOME

on Sunday, May 4, 2014



PART LIST:

ARDUINO UNO
LM35
8X4 7-SEGMENT DISPLAY
LDR
10 K OHM



CIRCUIT DIAGRAM:

SENSOR MODULE:





 
DISPLAY MODULE:



CODING:



  void setup()
{
  Serial.begin(9600);
  pinMode(6,OUTPUT);
  pinMode(7,OUTPUT);
  pinMode(8,OUTPUT);
  pinMode(9,OUTPUT);
  pinMode(13,OUTPUT);
  pinMode(11,OUTPUT);
  pinMode(10,OUTPUT);
  pinMode(12,OUTPUT);
  pinMode(2,OUTPUT);
    pinMode(3,OUTPUT);
     pinMode(4,OUTPUT);
    pinMode(5,OUTPUT);
     digitalWrite(2,HIGH);
  digitalWrite(3,HIGH);
    digitalWrite(4,HIGH);
  digitalWrite(5,HIGH);
}

void loop()
{
  unsigned int temp,ldr,a,c,d,b,q,r,s;

  temp=analogRead(A0);
 
     
s=temp*0.48828125;

      r=s/100;
      b=(s%100)/10;
      q=s%10;

ldr=analogRead(A1);
 int light = ldr *(100.0 / 1024.0);
      a=light/100;     
      c=(light%100)/10;
      d=light%10;
  if(b==0){
  digitalWrite(9,HIGH);// C
  digitalWrite(8,HIGH);//D
  digitalWrite(13,HIGH);//E
  digitalWrite(12,LOW);//G
  digitalWrite(11,HIGH);//F
  digitalWrite(6,HIGH);//A
  digitalWrite(7,HIGH);//B
  digitalWrite(2,HIGH);
  digitalWrite(3,LOW);
    digitalWrite(4,HIGH);
  digitalWrite(5,HIGH);
  digitalWrite(10,LOW);//dp
  }else if(b==1){
   digitalWrite(9,HIGH);
  digitalWrite(8,LOW);
  digitalWrite(13,LOW);
  digitalWrite(12,LOW);
  digitalWrite(11,LOW);
  digitalWrite(6,LOW);
  digitalWrite(7,HIGH);
  digitalWrite(2,HIGH);
  digitalWrite(3,LOW);
    digitalWrite(4,HIGH);
  digitalWrite(5,HIGH);
  digitalWrite(10,LOW);
  }
  else if(b==2){
  digitalWrite(9,LOW);// C
  digitalWrite(8,HIGH);//D
  digitalWrite(13,HIGH);//E
  digitalWrite(12,HIGH);//G
  digitalWrite(11,LOW);//F
  digitalWrite(6,HIGH);//A
  digitalWrite(7,HIGH);//B
  digitalWrite(2,HIGH);
  digitalWrite(3,LOW);
  digitalWrite(4,HIGH);
  digitalWrite(5,HIGH);
  digitalWrite(10,LOW);
  }
   else if(b==3){
  digitalWrite(9,HIGH);// C
  digitalWrite(8,HIGH);//D
  digitalWrite(13,LOW);//E
  digitalWrite(12,HIGH);//G
  digitalWrite(11,LOW);//F
  digitalWrite(6,HIGH);//A
  digitalWrite(7,HIGH);//B
  digitalWrite(2,HIGH);
  digitalWrite(3,LOW);
  digitalWrite(4,HIGH);
  digitalWrite(5,HIGH);
  digitalWrite(10,LOW);
  }
   else if(b==4){
digitalWrite(9,HIGH);// C
  digitalWrite(8,LOW);//D
  digitalWrite(13,LOW);//E
  digitalWrite(12,HIGH);//G
  digitalWrite(11,HIGH);//F
  digitalWrite(6,LOW);//A
  digitalWrite(7,HIGH);//B
  digitalWrite(2,HIGH);
  digitalWrite(3,LOW);
 digitalWrite(4,HIGH);
  digitalWrite(5,HIGH);
 digitalWrite(10,LOW);
}
   else if(b==5){
  digitalWrite(9,HIGH);// C
  digitalWrite(8,HIGH);//D
  digitalWrite(13,LOW);//E
  digitalWrite(12,HIGH);//G
  digitalWrite(11,HIGH);//F
  digitalWrite(6,HIGH);//A
  digitalWrite(7,LOW);//B
  digitalWrite(2,HIGH);
  digitalWrite(3,LOW);
  digitalWrite(4,HIGH);
  digitalWrite(5,HIGH);
  digitalWrite(10,LOW);
 }
   else if(b==6){
  digitalWrite(9,HIGH);// C
  digitalWrite(8,HIGH);//D
  digitalWrite(13,HIGH);//E
  digitalWrite(12,HIGH);//G
  digitalWrite(11,HIGH);//F
  digitalWrite(6,HIGH);//A
  digitalWrite(7,LOW);//B
  digitalWrite(2,HIGH);
  digitalWrite(3,LOW);
  digitalWrite(4,HIGH);
  digitalWrite(5,HIGH);
  digitalWrite(10,LOW);
 }
   else if(b==7){
  digitalWrite(9,HIGH);// C
  digitalWrite(8,LOW);//D
  digitalWrite(13,LOW);//E
  digitalWrite(12,LOW);//G
  digitalWrite(11,LOW);//F
  digitalWrite(6,HIGH);//A
  digitalWrite(7,HIGH);//B
  digitalWrite(2,HIGH);
  digitalWrite(3,LOW);
  digitalWrite(4,HIGH);
  digitalWrite(5,HIGH);
  digitalWrite(10,LOW);
   }
   else if(b==8){
  digitalWrite(9,HIGH);// C
  digitalWrite(8,HIGH);//D
  digitalWrite(13,HIGH);//E
  digitalWrite(12,HIGH);//G
  digitalWrite(11,HIGH);//F
  digitalWrite(6,HIGH);//A
  digitalWrite(7,HIGH);//B
  digitalWrite(2,HIGH);
  digitalWrite(3,LOW);
  digitalWrite(4,HIGH);
  digitalWrite(5,HIGH);
  digitalWrite(10,LOW);
  }
   else if(b==9){
  digitalWrite(9,HIGH);// C
  digitalWrite(8,HIGH);//D
  digitalWrite(13,LOW);//E
  digitalWrite(12,HIGH);//G
  digitalWrite(11,HIGH);//F
  digitalWrite(6,HIGH);//A
  digitalWrite(7,HIGH);//B
  digitalWrite(2,HIGH);
  digitalWrite(3,LOW);
  digitalWrite(4,HIGH);
  digitalWrite(5,HIGH);
  digitalWrite(10,LOW);
  }
   delay(2);
  if(q==0){
  digitalWrite(9,HIGH);// C
  digitalWrite(8,HIGH);//D
  digitalWrite(13,HIGH);//E
  digitalWrite(12,LOW);//G
  digitalWrite(11,HIGH);//F
  digitalWrite(6,HIGH);//A
  digitalWrite(7,HIGH);//B
  digitalWrite(3,HIGH);
  digitalWrite(2,LOW);
  digitalWrite(4,HIGH);
  digitalWrite(5,HIGH);
  digitalWrite(10,LOW);
  }else if(q==1){
   digitalWrite(9,HIGH);
  digitalWrite(8,LOW);
  digitalWrite(13,LOW);
  digitalWrite(12,LOW);
  digitalWrite(11,LOW);
  digitalWrite(6,LOW);
  digitalWrite(7,HIGH);
  digitalWrite(3,HIGH);
  digitalWrite(2,LOW);
  digitalWrite(4,HIGH);
  digitalWrite(5,HIGH);
  digitalWrite(10,LOW);
  }
  else if(q==2){
  digitalWrite(9,LOW);// C
  digitalWrite(8,HIGH);//D
  digitalWrite(13,HIGH);//E
  digitalWrite(12,HIGH);//G
  digitalWrite(11,LOW);//F
  digitalWrite(6,HIGH);//A
  digitalWrite(7,HIGH);//B
  digitalWrite(3,HIGH);
  digitalWrite(2,LOW);
  digitalWrite(4,HIGH);
  digitalWrite(5,HIGH);
  digitalWrite(10,LOW);
  }
   else if(q==3){
  digitalWrite(9,HIGH);// C
  digitalWrite(8,HIGH);//D
  digitalWrite(13,LOW);//E
  digitalWrite(12,HIGH);//G
  digitalWrite(11,LOW);//F
  digitalWrite(6,HIGH);//A
  digitalWrite(7,HIGH);//B
  digitalWrite(3,HIGH);
  digitalWrite(2,LOW);
  digitalWrite(4,HIGH);
  digitalWrite(5,HIGH);
  digitalWrite(10,LOW);
  }
   else if(q==4){
digitalWrite(9,HIGH);// C
  digitalWrite(8,LOW);//D
  digitalWrite(13,LOW);//E
  digitalWrite(12,HIGH);//G
  digitalWrite(11,HIGH);//F
  digitalWrite(6,LOW);//A
  digitalWrite(7,HIGH);//B
  digitalWrite(3,HIGH);
  digitalWrite(2,LOW); 
  digitalWrite(4,HIGH);
  digitalWrite(5,HIGH);
  digitalWrite(10,LOW);
}
   else if(q==5){
  digitalWrite(9,HIGH);// C
  digitalWrite(8,HIGH);//D
  digitalWrite(13,LOW);//E
  digitalWrite(12,HIGH);//G
  digitalWrite(11,HIGH);//F
  digitalWrite(6,HIGH);//A
  digitalWrite(7,LOW);//B
  digitalWrite(3,HIGH);
  digitalWrite(2,LOW);
  digitalWrite(4,HIGH);
  digitalWrite(5,HIGH);
  digitalWrite(10,LOW);
 }
   else if(q==6){
  digitalWrite(9,HIGH);// C
  digitalWrite(8,HIGH);//D
  digitalWrite(13,HIGH);//E
  digitalWrite(12,HIGH);//G
  digitalWrite(11,HIGH);//F
  digitalWrite(6,HIGH);//A
  digitalWrite(7,LOW);//B
  digitalWrite(3,HIGH);
  digitalWrite(2,LOW);
  digitalWrite(4,HIGH);
  digitalWrite(5,HIGH);
  digitalWrite(10,LOW);
 }
   else if(q==7){
  digitalWrite(9,HIGH);// C
  digitalWrite(8,LOW);//D
  digitalWrite(13,LOW);//E
  digitalWrite(12,LOW);//G
  digitalWrite(11,LOW);//F
  digitalWrite(6,HIGH);//A
  digitalWrite(7,HIGH);//B
  digitalWrite(3,HIGH);
  digitalWrite(2,LOW);
  digitalWrite(4,HIGH);
  digitalWrite(5,HIGH);
  digitalWrite(10,LOW);
   }
   else if(q==8){
  digitalWrite(9,HIGH);// C
  digitalWrite(8,HIGH);//D
  digitalWrite(13,HIGH);//E
  digitalWrite(12,HIGH);//G
  digitalWrite(11,HIGH);//F
  digitalWrite(6,HIGH);//A
  digitalWrite(7,HIGH);//B
  digitalWrite(3,HIGH);
  digitalWrite(2,LOW);
  digitalWrite(4,HIGH);
  digitalWrite(5,HIGH);
  digitalWrite(10,LOW);
  }
   else if(q==9){
  digitalWrite(9,HIGH);// C
  digitalWrite(8,HIGH);//D
  digitalWrite(13,LOW);//E
  digitalWrite(12,HIGH);//G
  digitalWrite(11,HIGH);//F
  digitalWrite(6,HIGH);//A
  digitalWrite(7,HIGH);//B
  digitalWrite(3,HIGH);
  digitalWrite(2,LOW);
  digitalWrite(4,HIGH);
  digitalWrite(5,HIGH);
  digitalWrite(10,LOW);
  }
 
  delay(2);

   if(c==0){
    digitalWrite(9,HIGH);// C
  digitalWrite(8,HIGH);//D
  digitalWrite(13,HIGH);//E
  digitalWrite(12,LOW);//G
  digitalWrite(11,HIGH);//F
  digitalWrite(6,HIGH);//A
  digitalWrite(7,HIGH);//B
  digitalWrite(2,HIGH);
  digitalWrite(3,HIGH);
    digitalWrite(4,HIGH);
  digitalWrite(5,LOW);
    digitalWrite(10,LOW);
   
    }else if(c==1){
       digitalWrite(9,HIGH);
  digitalWrite(8,LOW);
  digitalWrite(13,LOW);
  digitalWrite(12,LOW);
  digitalWrite(11,LOW);
  digitalWrite(6,LOW);
  digitalWrite(7,HIGH);
  digitalWrite(2,HIGH);
  digitalWrite(3,HIGH);
    digitalWrite(4,HIGH);
  digitalWrite(5,LOW);
  digitalWrite(10,LOW);
    }else if(c==2){
     digitalWrite(9,LOW);// C
  digitalWrite(8,HIGH);//D
  digitalWrite(13,HIGH);//E
  digitalWrite(12,HIGH);//G
  digitalWrite(11,LOW);//F
  digitalWrite(6,HIGH);//A
  digitalWrite(7,HIGH);//B
  digitalWrite(2,HIGH);
  digitalWrite(3,HIGH);
  digitalWrite(4,HIGH);
  digitalWrite(5,LOW);
  digitalWrite(10,LOW);
    }else if(c==3){
      digitalWrite(9,HIGH);// C
  digitalWrite(8,HIGH);//D
  digitalWrite(13,LOW);//E
  digitalWrite(12,HIGH);//G
  digitalWrite(11,LOW);//F
  digitalWrite(6,HIGH);//A
  digitalWrite(7,HIGH);//B
  digitalWrite(2,HIGH);
  digitalWrite(3,HIGH);
  digitalWrite(4,HIGH);
  digitalWrite(5,LOW);
  digitalWrite(10,LOW);
    }else if(c==4){
    digitalWrite(9,HIGH);// C
  digitalWrite(8,LOW);//D
  digitalWrite(13,LOW);//E
  digitalWrite(12,HIGH);//G
  digitalWrite(11,HIGH);//F
  digitalWrite(6,LOW);//A
  digitalWrite(7,HIGH);//B
  digitalWrite(2,HIGH);
  digitalWrite(3,HIGH);
 digitalWrite(4,HIGH);
  digitalWrite(5,LOW);
  digitalWrite(10,LOW);
    }else if(c==5){
      digitalWrite(9,HIGH);// C
  digitalWrite(8,HIGH);//D
  digitalWrite(13,LOW);//E
  digitalWrite(12,HIGH);//G
  digitalWrite(11,HIGH);//F
  digitalWrite(6,HIGH);//A
  digitalWrite(7,LOW);//B
  digitalWrite(2,HIGH);
  digitalWrite(3,HIGH);
  digitalWrite(4,HIGH);
  digitalWrite(5,LOW);
  digitalWrite(10,LOW);
    }else if(c==6){
    digitalWrite(9,HIGH);// C
  digitalWrite(8,HIGH);//D
  digitalWrite(13,HIGH);//E
  digitalWrite(12,HIGH);//G
  digitalWrite(11,HIGH);//F
  digitalWrite(6,HIGH);//A
  digitalWrite(7,LOW);//B
  digitalWrite(2,HIGH);
  digitalWrite(3,HIGH);
  digitalWrite(4,HIGH);
  digitalWrite(5,LOW);
  digitalWrite(10,LOW);
    }else if(c==7){
     digitalWrite(9,HIGH);// C
  digitalWrite(8,LOW);//D
  digitalWrite(13,LOW);//E
  digitalWrite(12,LOW);//G
  digitalWrite(11,LOW);//F
  digitalWrite(6,HIGH);//A
  digitalWrite(7,HIGH);//B
  digitalWrite(2,HIGH);
  digitalWrite(3,HIGH);
  digitalWrite(4,HIGH);
  digitalWrite(5,LOW);
  digitalWrite(10,LOW);
    }else if(c==8){
      digitalWrite(9,HIGH);// C
  digitalWrite(8,HIGH);//D
  digitalWrite(13,HIGH);//E
  digitalWrite(12,HIGH);//G
  digitalWrite(11,HIGH);//F
  digitalWrite(6,HIGH);//A
  digitalWrite(7,HIGH);//B
  digitalWrite(3,HIGH);
  digitalWrite(2,HIGH);
  digitalWrite(4,HIGH);
  digitalWrite(5,LOW);
  digitalWrite(10,LOW);
    }else if(c==9){
     digitalWrite(9,HIGH);// C
  digitalWrite(8,HIGH);//D
  digitalWrite(13,LOW);//E
  digitalWrite(12,HIGH);//G
  digitalWrite(11,HIGH);//F
  digitalWrite(6,HIGH);//A
  digitalWrite(7,HIGH);//B
  digitalWrite(3,HIGH);
  digitalWrite(2,HIGH);
  digitalWrite(4,HIGH);
  digitalWrite(5,LOW);
  digitalWrite(10,LOW);
    }
delay(2);
       if(d==0){
    digitalWrite(9,HIGH);// C
  digitalWrite(8,HIGH);//D
  digitalWrite(13,HIGH);//E
  digitalWrite(12,LOW);//G
  digitalWrite(11,HIGH);//F
  digitalWrite(6,HIGH);//A
  digitalWrite(7,HIGH);//B
  digitalWrite(2,HIGH);
  digitalWrite(3,HIGH);
    digitalWrite(4,LOW);
  digitalWrite(5,HIGH);
    digitalWrite(10,HIGH);
   
    }else if(d==1){
       digitalWrite(9,HIGH);
  digitalWrite(8,LOW);
  digitalWrite(13,LOW);
  digitalWrite(12,LOW);
  digitalWrite(11,LOW);
  digitalWrite(6,LOW);
  digitalWrite(7,HIGH);
  digitalWrite(2,HIGH);
  digitalWrite(4,LOW);
    digitalWrite(3,HIGH);
  digitalWrite(5,HIGH);
  digitalWrite(10,HIGH);
    }else if(d==2){
     digitalWrite(9,LOW);// C
  digitalWrite(8,HIGH);//D
  digitalWrite(13,HIGH);//E
  digitalWrite(12,HIGH);//G
  digitalWrite(11,LOW);//F
  digitalWrite(6,HIGH);//A
  digitalWrite(7,HIGH);//B
  digitalWrite(2,HIGH);
  digitalWrite(4,LOW);
  digitalWrite(3,HIGH);
  digitalWrite(5,HIGH);
  digitalWrite(10,HIGH);
    }else if(d==3){
      digitalWrite(9,HIGH);// C
  digitalWrite(8,HIGH);//D
  digitalWrite(13,LOW);//E
  digitalWrite(12,HIGH);//G
  digitalWrite(11,LOW);//F
  digitalWrite(6,HIGH);//A
  digitalWrite(7,HIGH);//B
  digitalWrite(2,HIGH);
  digitalWrite(4,LOW);
  digitalWrite(3,HIGH);
  digitalWrite(5,HIGH);
  digitalWrite(10,HIGH);
    }else if(d==4){
    digitalWrite(9,HIGH);// C
  digitalWrite(8,LOW);//D
  digitalWrite(13,LOW);//E
  digitalWrite(12,HIGH);//G
  digitalWrite(11,HIGH);//F
  digitalWrite(6,LOW);//A
  digitalWrite(7,HIGH);//B
  digitalWrite(2,HIGH);
  digitalWrite(4,LOW);
 digitalWrite(3,HIGH);
  digitalWrite(5,HIGH);
  digitalWrite(10,HIGH);
    }else if(d==5){
      digitalWrite(9,HIGH);// C
  digitalWrite(8,HIGH);//D
  digitalWrite(13,LOW);//E
  digitalWrite(12,HIGH);//G
  digitalWrite(11,HIGH);//F
  digitalWrite(6,HIGH);//A
  digitalWrite(7,LOW);//B
  digitalWrite(2,HIGH);
  digitalWrite(4,LOW);
  digitalWrite(3,HIGH);
  digitalWrite(5,HIGH);
  digitalWrite(10,HIGH);
    }else if(d==6){
    digitalWrite(9,HIGH);// C
  digitalWrite(8,HIGH);//D
  digitalWrite(13,HIGH);//E
  digitalWrite(12,HIGH);//G
  digitalWrite(11,HIGH);//F
  digitalWrite(6,HIGH);//A
  digitalWrite(7,LOW);//B
  digitalWrite(2,HIGH);
  digitalWrite(4,LOW);
  digitalWrite(3,HIGH);
  digitalWrite(5,HIGH);
  digitalWrite(10,HIGH);
    }else if(d==7){
     digitalWrite(9,HIGH);// C
  digitalWrite(8,LOW);//D
  digitalWrite(13,LOW);//E
  digitalWrite(12,LOW);//G
  digitalWrite(11,LOW);//F
  digitalWrite(6,HIGH);//A
  digitalWrite(7,HIGH);//B
  digitalWrite(2,HIGH);
  digitalWrite(4,LOW);
  digitalWrite(3,HIGH);
  digitalWrite(5,HIGH);
  digitalWrite(10,HIGH);
    }else if(d==8){
      digitalWrite(9,HIGH);// C
  digitalWrite(8,HIGH);//D
  digitalWrite(13,HIGH);//E
  digitalWrite(12,HIGH);//G
  digitalWrite(11,HIGH);//F
  digitalWrite(6,HIGH);//A
  digitalWrite(7,HIGH);//B
  digitalWrite(3,HIGH);
  digitalWrite(4,LOW);
  digitalWrite(2,HIGH);
  digitalWrite(5,HIGH);
  digitalWrite(10,HIGH);
    }else if(d==9){
     digitalWrite(9,HIGH);// C
  digitalWrite(8,HIGH);//D
  digitalWrite(13,LOW);//E
  digitalWrite(12,HIGH);//G
  digitalWrite(11,HIGH);//F
  digitalWrite(6,HIGH);//A
  digitalWrite(7,HIGH);//B
  digitalWrite(3,HIGH);
  digitalWrite(2,HIGH);
  digitalWrite(4,LOW);
  digitalWrite(5,HIGH);
digitalWrite(10,HIGH); 
  }
delay(2);
}

0 comments:

Post a Comment