Objective: Ganpati decoration using ardiouno and relay driver circuit.


Step: Material required
1)Arduino
2)Ultrasonic sensor
3)Motion sensor
4)Power supply
5)Socket
Step:2 Power supply material.
1)  Transformer(230v AC TO12vAC)-01
2)  Diode(IN4007)-04
3)  Capacitor(1000microfarad)-01
4)  Ceramic capacitor(104)-01
5)   Voltage regulater(7812/7805)-1each.

Stap:3 how to make power supply.
First take a diode and make a diode bridge then take a transformer join + ve to diode –ve and –ve to +ve  then take a capacitor and the capacitor to diode +ve –ve then take a ceramic capacitor and join the capacitor to any way because ceramic capacitor not any +ve  -ve then take a 7805 regulator and join + to regulator and –ve to ground our power supply is complete.
 If you want a 5 volt power supply, just simply replace the LM7812 to a LM7805 regulator.F6ZDVT6FKVQJ2RJ.MEDIUM.jpg
Stap:4)How to pin motion sensor to ardiouno.
Arduino-PIR-Sensor-dection-motion-01.jpg
Power the PIR with 5V and connect ground to ground.
 Then connect the output to a digital pin. In this example we'll use pin 2.
Stap:5) How to pin ultrasonic sensor to ardiouno.
schematics.png
intvcc = 2; //attach pin 2 to vcc
int trig = 3; // attach pin 3 to Trig
int echo = 4; //attach pin 4 to Echo
intgnd = 5; //attach pin 5 to GND
step:6)Arduino  programming.
/*

HC-SR04 Ping distance sensor:

VCC to arduino 5v

GND to arduino GND

Echo to Arduino pin 9

Trig to Arduino pin 8*/

#define echopin 9 // echo pin
#define trigpin 8 // Trigger pin
int maximumRange = 50;
long duration, distance;
int calibrationTime = 15;       

//the time when the sensor outputs a low impulse
long unsigned int lowIn;        
//the amount of milliseconds the sensor has to be low
//before we assume all motion has stopped
long unsigned int pause = 5000; 

boolean lockLow = true;
boolean takeLowTime; 

int pirPin = 2;    //the digital pin connected to the PIR sensor's output
int ledPin = 13;

void setup() {

Serial.begin (9600);
  pinMode (trigpin, OUTPUT);
  pinMode (echopin, INPUT );

  pinMode (4, OUTPUT);
  pinMode (3, OUTPUT);
  pinMode (13,OUTPUT);
   pinMode (12, OUTPUT);
  pinMode (11,OUTPUT);


  pinMode(pirPin, INPUT);
  pinMode(ledPin, OUTPUT);
  digitalWrite(pirPin, LOW);
  digitalWrite(3,HIGH);
  digitalWrite(12,HIGH);
  digitalWrite(11,LOW);
  Serial.print("calibrating sensor ");
    for(int i = 0; i < calibrationTime; i++){
      Serial.print(".");
      delay(1000);
      }
    Serial.println(" done");
    Serial.println("SENSOR ACTIVE");
    delay(50);


  //give the sensor some time to calibrate
 

}

void loop ()

{

 
  digitalWrite(trigpin,LOW);
  delayMicroseconds(2);
  digitalWrite(trigpin,HIGH);
  delayMicroseconds(10);
  duration=pulseIn (echopin,HIGH);
  distance= duration/58.2;
  Serial.println(distance);
  delay (50);
  if(digitalRead(pirPin) == HIGH){
       digitalWrite(ledPin, HIGH);   //the led visualizes the sensors output pin state
       delay(5000);
       if(lockLow){ 
         //makes sure we wait for a transition to LOW before any further output is made:
         lockLow = false;           
         Serial.println("---");
         Serial.print("motion detected at ");
         Serial.print(millis()/1000);
         Serial.println(" sec");
         delay(1000);
         }        
         takeLowTime = true;
       }

     if(digitalRead(pirPin) == LOW){      
       digitalWrite(ledPin, LOW);  //the led visualizes the sensors output pin state

       if(takeLowTime){
        lowIn = millis();          //save the time of the transition from high to LOW
        takeLowTime = false;       //make sure this is only done at the start of a LOW phase
        }
       //if the sensor is low for more than the given pause,
       //we assume that no more motion is going to happen
       if(!lockLow && millis() - lowIn > pause){ 
           //makes sure this block of code is only executed again after
           //a new motion sequence has been detected
           lockLow = true;                       
           Serial.print("motion ended at ");      //output
           Serial.print((millis() - pause)/1000);
           Serial.println(" sec");
           delay(1000);
           }
       }
if (distance <200)
{
digitalWrite (4,HIGH);
delay(100);
digitalWrite (4,LOW);
delay(100);
}

else if ( 200< distance <600)
{
  digitalWrite (4,HIGH);
  delay(100);
  digitalWrite (4,LOW);
  delay(100);
}
else
{
  digitalWrite (4,HIGH);
  delay(3000);
  digitalWrite (4,LOW);
  delay(3000);
}


}


Comments

Popular posts from this blog