loading

On this instructables, I will share how to build security system with atmega8 arduino,

Step 1: Building an Arduino Standalone With Atmega8

Check here : http://arduino.cc/en/Main/Standalone

or you can use any type of arduino

Step 2: Wire the LDR, BUZZER and Led

Connect LDR to 5v and A0,

from A0 use resistor any value to GND

LED to pin13 and GND

buzzer to pin7

Step 3: Soldering Potensiometers

Solder pin1 to GND arduino

pin2 to A1 arduino

pin3 to 5v arduino

Step 4: Wire Laser Diode

Wire blue cable to GND and Red to 5v

or use 3-5v battery

Step 5: Soldering USB Jack

use usb jack for the power of my project, so the project can work from a laptop or pc

wire the + pin to 5+ arduino and GND to GND arduino,

Step 6: The Code

int sensorPin = A0;  
int potensioPin = A1; int ledPin = 13; int sensorValue = 0; int potensioValue = 0; int laserPin = 12; void setup() { //Serial.begin(9600); pinMode(ledPin, OUTPUT); pinMode(2, OUTPUT); pinMode(5, OUTPUT); pinMode(6, OUTPUT); pinMode(7, OUTPUT); pinMode(8, OUTPUT); pinMode(9, OUTPUT); pinMode(10, OUTPUT); pinMode(11, OUTPUT); pinMode(laserPin, OUTPUT); } void loop() { digitalWrite(laserPin, HIGH); sensorValue = analogRead(sensorPin); potensioValue = analogRead(potensioPin); sensorValue = map(sensorValue, 0, 1023, 0, 100); potensioValue = map(potensioValue, 0, 1023, 0, 100); //Serial.println(potensioValue); if(sensorValue < 99){ digitalWrite(5, HIGH); digitalWrite(6, HIGH); digitalWrite(7, HIGH); digitalWrite(8, HIGH); digitalWrite(9, HIGH); digitalWrite(10, HIGH); digitalWrite(11, HIGH); for(int i=0; i <= potensioValue; i++){ digitalWrite(ledPin, HIGH); delay(100); digitalWrite(ledPin, LOW); delay(100); buzz(7, 2500, 200); buzz(9, 2500, 200); if(i == potensioValue) { buzz(2, 2500, 100 * potensioValue); buzz(9, 2500, 100 * potensioValue); digitalWrite(5, LOW); digitalWrite(6, LOW); digitalWrite(7, LOW); digitalWrite(8, LOW); digitalWrite(9, LOW); digitalWrite(10, LOW); digitalWrite(11, LOW); } } } } void buzz(int targetPin, long frequency, long length) { long delayValue = 1000000/frequency/2; long numCycles = frequency * length/ 1000; for (long i=0; i < numCycles; i++){ digitalWrite(targetPin,HIGH); delayMicroseconds(delayValue); digitalWrite(targetPin,LOW); delayMicroseconds(delayValue); } }

thanks to read this instructables and i hope this useful..

About This Instructable

2,471views

42favorites

License:

More by djsamm88:Build Laser security system with atmega8 (arduino) 
Add instructable to: