Switch w/ Arduino

Concept

I tried to make an ironic switch.

When you close the bottle, LED turns on inside of bottle.

But at the same time, the photocell sensor catch the light of LED and make the it turns off. This weird situation keeps going on.

The result of this is blinking LED inside of the dark bottle.

 

 

Sensor: Photocell

Setting:

If the photocell sense the light = Turn off the LED

If it’s dark = Turn on the LED

img_0391-1

 

img_0398

img_0399

img_0406_2

 

 

Arduino 
//Analog Pin
int photo = A0; // photocell is connected to A0
int brightness;

//Digital Pin
int LED = 10; // LED is connected to 10 (INPUT)
int fade; //to make LED dim
void setup() {
Serial.begin(9600);
pinMode(LED, OUTPUT); // LED turn on
}
void loop() {

brightness = analogRead(photo);//get analog input from photo(A0)
if (brightness <400){
digitalWrite(LED, HIGH);
}else{
digitalWrite(LED, LOW);
}
delay(100);

// to see the number of value
Serial.print(“mapped value: “);
Serial.print(fade);
Serial.print(” “);
Serial.print(“POT: “);
Serial.println(brightness);

}

Leave a Reply

Your email address will not be published. Required fields are marked *