This is a light activated alarm that uses the photo resistor. When lights are on the front red LED blinks steadily, and when the lights are off the buzzer goes off along with the two back green and red LEDs.

B.O.M.(Bill Of Materials)

<> 1 -- Arduino Uno

<> 1 -- Prototyping Shield Optional

<> 12 -- Wires

<> 1 -- Breadboard

<> 1 -- Buzzer (piezoelectric) 12mm

<> 2 -- Red LEDs 3mm

<> 1 -- Green LED 3mm

<> 1 -- Photo Resistor

<> 3 -- 10kΩ Resistor

<> 1 -- 1kΩ Resistor


I'm not that good at explaining things so I'm not going to explain how to put it together here. I've included the .fzz file for that purpose, but if you have any questions I would be glad to answer them. I've also included the program, but I'll paste it below for those who like to copy and paste.

Created by: HailStorm

Created on 12/31/13

Please give me credit if reproducing this code or project


CODE:

/* This is a light activated alarm that uses the photo resistor. When lights are on the front red LED blinks steadily, and when the lights are off the buzzer goes off along with the two back green and red LEDs.

Created by: HailStorm

Created on 12/31/13

Project ULR for BOM and diogram: http://fritzing.org/projects/light-activated-alarm

Please give credit if reproducing this code or project

*/

const int photo = 3; //Pin # for photo resistor const int ledPin = 9; //Pin # for first red LED const int buzzer = 11; //Pin # for buzzer const int leds1 = 13; //Pin # for second red LED const int leds2 = 7; //Pin # for first green LED

void setup() { Serial.begin(9600); //Set up serial monitor (for debugging purposes)

//Set up pins//
pinMode(photo, INPUT); pinMode(ledPin, OUTPUT); pinMode(buzzer, OUTPUT); pinMode(leds1, OUTPUT); pinMode(leds2, OUTPUT); }

void loop()

{

int sensorV = digitalRead(photo); //Set sensorV eqaul to digital vale of photo resistor

Serial.println(sensorV); //Display sensorV on serial monitor

if(sensorV == 1)

{ digitalWrite(ledPin, HIGH); //Turn first red LED on delay(900); //Wait 900ms digitalWrite(ledPin, LOW); //Turn off first red LED off

//Set other red LED and green LED to LOW//
digitalWrite(leds2, LOW); digitalWrite(leds1, LOW); }

sensorV = digitalRead(photo); //Set sensorV eqaul to digital vale of photo resistor

Serial.println(sensorV); //Display sensorV on serial monitor

if(sensorV == 0)

{ digitalWrite(ledPin, LOW); //Turn first LED off digitalWrite(buzzer, HIGH); //Turn buzzer on digitalWrite(leds2, LOW); //Set green LED to LOW digitalWrite(leds1, HIGH); //Turn 2nd red LED on delay(900); //Wait 900ms digitalWrite(buzzer, LOW); //Turn buzzer off digitalWrite(leds1, LOW); //Turn 2nd red LED off digitalWrite(leds2, HIGH); //Turn green LED on delay(900); //Wait 900ms } delay(500); //Delay for 500ms (let things catch up) }