Tag Archives: arduino

lightning detector

Lightning Detector for Arduino

Lightning Detector for Arduino

Hardware required

Arduino
Breadboard
Jumper Wires

Components

2 – 10k Ohms Resistor
1 – 3.3M Ohms Resistor

Price of components = 20npr

lightning detector
lightning detector

Arduino code

#define FASTADC 1

#define FASTADC 1

// defines for setting and clearing register bits
#ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#endif
#ifndef sbi
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif

int data = 512;
int storage[512];

long batchStarted;
long batchEnded;
int reading;
int count;
int maximum;
int minimum;
bool toSend;

void setup() {
#if FASTADC
// set prescale to 16
sbi(ADCSRA,ADPS2) ;
cbi(ADCSRA,ADPS1) ;
cbi(ADCSRA,ADPS0) ;
#endif
// put your setup code here, to run once:
Serial.begin(115200);
pinMode(A4,INPUT);
Serial.println(micros());

batchStarted=0;
batchEnded=0;
reading=0;
count=0;
maximum=0;
minimum=1023;
toSend=false;
}

void loop() {
// put your main code here, to run repeatedly:
reading = (analogRead(A4));
storage[count]=reading;
if ((!toSend)&&(count!=0)&&((reading>storage[count-1]+10)||(reading>>”);
Serial.println(batchStarted);

for (int i=0;i

Night Lamp

Smart Night Lamp

Smart Night Lamp

Hardware

Arduino
Jumper wires
Breadboard

Components
1 – Bright RGB Cathode LED
1 – Photo Resistor
2 – 220 Ohm Resistors
1 – 330 Ohm Resistor
1 – 10K Ohm Resistor

Price of components is 100npr

Circuit diagram

Night Lamp
Night Lamp

Arduino Code

int photoSensorPin = A0;
int redLedPin = 3;
int greenLedPin = 5;
int blueLedPin = 6;
int redLedVal = 0;
int greenLedVal = 0;
int blueLedVal = 0;
boolean isLedOn = false;

int brightness = 1023;
int darkThreshold = 50;
int changeColorTime = 900000;

long lastUpdate=0;

void setup()
{
randomSeed(analogRead(1));
}

void loop()
{
getBrightness();
if (brightnesslastUpdate+changeColorTime)
{
LedOn();
isLedOn = true;
lastUpdate = millis();
}
}
else {
LedOff();
isLedOn = false;
}

delay(1000);
}

int getBrightness()
{
brightness = analogRead(photoSensorPin);
return brightness;
}

void LedOn()
{
redLedVal = random(1,128);
greenLedVal = random(1,128);
blueLedVal = random(1,128);

analogWrite(redLedPin,redLedVal);
analogWrite(greenLedPin,greenLedVal);
analogWrite(blueLedPin,blueLedVal);
}

void LedOff(){

analogWrite(redLedPin,0);
analogWrite(greenLedPin,0);
analogWrite(blueLedPin,0);
}

Arduino-L.E.D-Police-Lights-circuit

Simple Arduino L.E.D Police Lights

Simple Arduino L.E.D Police Lights

Arduino (or suitable clone)
Breadboard

Components
2x 330ohm resistors
1x Clear Red l.e.d
1x Clear Blue l.e.d

Price of components in Nepal = 24npr

Some Jumper Cables

Code to be uploaded on to the Arduino

// Project 1 – Police Lights by Dave1324

int ledDelay = 50; // delay by 50ms
int redPin = 9;
int bluePin = 11;

void setup() {
pinMode(redPin, OUTPUT);
pinMode(bluePin, OUTPUT);

}

Arduino L.E.D Police Lights circuit
void loop() {

digitalWrite(redPin, HIGH); // turn the red light on
delay(ledDelay); // wait 50 ms

digitalWrite(redPin, LOW); // turn the red light off
delay(ledDelay); // wait 50 ms

digitalWrite(redPin, HIGH); // turn the red light on
delay(ledDelay); // wait 50 ms

digitalWrite(redPin, LOW); // turn the red light off
delay(ledDelay); // wait 50 ms

digitalWrite(redPin, HIGH); // turn the red light on
delay(ledDelay); // wait 50 ms

digitalWrite(redPin, :LOW); // turn the red light off
delay(ledDelay); // wait 50 ms

delay(100); // delay midpoint by 100ms

digitalWrite(bluePin, HIGH); // turn the blue light on
delay(ledDelay); // wait 50 ms

digitalWrite(bluePin, LOW); // turn the blue light off
delay(ledDelay); // wait 50 ms

}

 

Arduino-L.E.D-Police-Lights-circuit
Arduino-L.E.D-Police-Lights-circuit
Arduino-Based-Shadow-Alarm-Schematic

Arduino-Based Shadow Alarm

Arduino-Based Shadow Alarm

Arduino-Based-Shadow-Alarm-Schematic
Arduino-Based-Shadow-Alarm-Schematic

Shadow alarms are usually used for protection against theft. A shadow alarm is a device that sounds an alarm when a shadow falls on it.Described here is a simple circuit of an arduino based shadow alarm.This compact shadow alarm unit is capable of sensing a moving shadow in a restricted area, and can be easily installed on wall, window or door to protect your valuables from theft.Constant lighting is required in the confined area to detect the moving shadow.

Components

T1, T2 – BC547
D1,D2 – 1N4007
LED – 5mm light emitting diode
R1,R4 – 1k resistor
R2,R3 – 470 ohm resistor
VR1 – 4.7k preset
LDR – Light dependent resistor
C1 – 470uf, 25v electrolytic capacitor
C2 – 100uf, 16v electrolytic capacitor
CON1 – 7 pin male header
CON2 – 1 pin male header

Price from us for above = 150npr

Batt.1 – 9v battery
Arduino Uno
Wires

Programming

1) Connect arduino to your PC

2) Input this source code:

//shadow alarm by Jovian D’souza
int sensPin = 2; // Sensor Input Pin
int ledPin = 8; // Reminder LED Output Pin
int pzSpeaker = 10; // Piezo-speaker Output Pin
int val =0; // variable for reading the Input Pin status

void setup() {
pinMode(sensPin, INPUT); // set shadow sensor as input
pinMode(ledPin, OUTPUT); // set LED as Output
pinMode(pzSpeaker, OUTPUT); // Set Piezo-speaker as Output
}
void loop() {
val = digitalRead(sensPin); // read input value
if (val == HIGH) { // check if the input is HIGH
digitalWrite(ledPin, HIGH); // Turn LED ON
playTone(500, 600);
delay(100);
playTone(500, 800);
delay(100);
}
else {
playTone(0, 0);
delay(300);
}
}
// duration in milli seconds , frequency in hertz
void playTone (long duration, int freq) {
duration *= 1000;
int period = (1.0 / freq) * 1000000;
long elapsed_time = 0;
while (elapsed_time < duration) {
digitalWrite(pzSpeaker, HIGH);
delayMicroseconds(period / 2);
digitalWrite(pzSpeaker, LOW);
delayMicroseconds(period / 2);
elapsed_time += (period);
}
}

 

3) Click on upload

Step 5: Connections to and from Arduino and board

1) Connect the 1st pin of the shadow alarm circuit to Vin of the arduino.
2) Connect the 2nd pin of the shadow alarm circuit to pin 10 of the arduino.
3) Connect the 3rd pin of the shadow alarm circuit to the LDR and other pin of LDR to Gnd.
4) Connect the 4th pin of the shadow alarm circuit to 5v of the arduino.
5) Connect the 5th pin of the shadow alarm circuit to pin 8 of the arduino.
6) Connect the 6th pin of the shadow alarm circuit to pin 2 of the arduino.
7) Connect the 7th pin of the shadow alarm circuit to Gnd of the arduino.