Light Sensitive Worm Using Arduino Uno
by ProbhakarS in Circuits > Arduino
870 Views, 3 Favorites, 0 Comments
Light Sensitive Worm Using Arduino Uno
Hey guys, after a long time I am writing. I hope you guys are all good. Today I am writing an easy instructable but you will get fun from it, confirmed!
Required Components:-
1.Arduino Uno
2.LDR(light dependent resistor)
3.LED (10 pieces)
4.Resistor(100 ohm and 100K)
5.Male to Male jumpers
6.Bread board
Attach All of Them According to the Picture
Required Code:-
int LDRvalue=0;
int LDRsensitivity=400;
void setup()
{ pinMode(13,OUTPUT);
pinMode(12,OUTPUT);
pinMode(11,OUTPUT);
pinMode(10,OUTPUT);
pinMode(9,OUTPUT);
pinMode(8,OUTPUT);
pinMode(7,OUTPUT);
pinMode(6,OUTPUT);
pinMode(5,OUTPUT);
pinMode(4,OUTPUT);
Serial.begin(9600); }
void loop() {
int i=13;
int j=12;
for(int k=0;i<=13&&i>=4&&j<=12&&i>=4;k=k+1){
LDRvalue=analogRead(A0);
Serial.println(LDRvalue);
if(LDRvalue>LDRsensitivity){
Serial.println(i);
Serial.println(j);
digitalWrite(i,HIGH);
digitalWrite(j,HIGH);
delay(100);
digitalWrite(i,LOW);
digitalWrite(j,LOW);
i=i-1;
j=j-1;
delay(100);
}
else{
Serial.println(i);
Serial.println(j);
digitalWrite(i,HIGH);
digitalWrite(j,HIGH);
delay(100);
digitalWrite(i,LOW);
digitalWrite(j,LOW);
i=i+1;
j=j+1;
delay(100);
}
}
}
See My Video on Youtube
Thank You.