This is a very basic light seeker circuit,
using a analog input of the Attiny to read the difference in light on LDR1 and LDR2.
If you build this for a robot, use motors instead of the LEDs and change the "analogWrite" values 0 to something else. For example 50. (I used 0 to see the difference clearly in the video)
using a analog input of the Attiny to read the difference in light on LDR1 and LDR2.
If you build this for a robot, use motors instead of the LEDs and change the "analogWrite" values 0 to something else. For example 50. (I used 0 to see the difference clearly in the video)
Arduino code:
int led1 = 0;
int led2 = 1;
int ldr = 2;
int light;
void setup() {
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
}
void loop() {
light = analogRead(ldr);
if(light<511){analogWrite(led1,0); analogWrite(led2,255);}
else{
analogWrite(led1,255); analogWrite(led2,0);}
}
int led1 = 0;
int led2 = 1;
int ldr = 2;
int light;
void setup() {
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
}
void loop() {
light = analogRead(ldr);
if(light<511){analogWrite(led1,0); analogWrite(led2,255);}
else{
analogWrite(led1,255); analogWrite(led2,0);}
}