automatic street light
* code *
#define sensorpin A0
int sensorvalue = 0;
#define signalpin 7
#define led1 13
void setup()
{
pinMode(sensorpin,INPUT);
pinMode(signalpin,OUTPUT);
pinMode(led1,OUTPUT);
Serial.begin(9600);
}
void loop()
{
sensorvalue = analogRead(sensorpin);
int level = map(sensorvalue,1024,0,255,0);
analogWrite(led1,level);
Serial.println(level);
if(sensorvalue <= 235)
{
digitalWrite(7,HIGH);
//Serial.println("LED IS ON...");
}
else
{
digitalWrite(7,LOW);
//Serial.println("LED IS OFF");
}
}
Comments
Post a Comment