Automated Desk Lamp (with ARDUINO and HC-SR04)hjh

Introduction: Automated Desk Lamp (with ARDUINO and HC-SR04)hjh

About: I love all things related to electronics . Follow me for awesome instructables. Arduino ,linkit one, pro mini etc. familiar with these microcontrollers .

HELLO...........................AADABH...........................NAMASTE.............

THIS PROJECT IS VERY USEFUL .BY THIS WE COULD BE FREE OF OUR PARENTS CHARGE WHEN WE LEAVE OUR ELECTRONIC APPLIANCES ON AND THEN THEY GET ON........... ON US..........

WHAT IT IS::

IN THIS PROJECT THE ELECTRONIC APPLIANCE IS A LAMP .............

WHEN YOU WILL SIT ON YOUR DESK THE LAMP WILL ILLUMINATE AND WHEN YOU WILL LEAVE YOUR DESK IT WILL TURN OFF

PLEASE VOTE FOR ME IN THE CONTEST

Step 1: PARTS

THIS PROJECT REQUIRES VERY FEW PARTS

1. ARDUINO UNO or NANO/1

2. HC-SR04(ULTRASONIC SENSOR)

3. USB CABLE

4. ARDUINO INSTALLED IN YOUR COMPUTER(1.0.6 OR ABOVE)

5. JUMPER WIRES

6. ANY ELECTRICAL APPLIANCE(I am using a desk lamp)

7. 9V battery

8.BATTERY HOLDER

9. SWITCH

10. BREAD BOARD

Step 2: CODE

const int trig = 2;

const int echo = 3;

const int relay = 4;

long duration, distanceCm;

int limitCm = 15;

void setup() {

Serial.begin(9600);

pinMode(relay, OUTPUT);

}

void loop() {

pinMode(trig, OUTPUT);

digitalWrite(trig, LOW);

delayMicroseconds(2);

digitalWrite(trig, HIGH);

delayMicroseconds(5);

digitalWrite(trig, LOW);

pinMode(echo,INPUT);

duration = pulseIn(echo ,HIGH);

distanceCm = microsecondsToCm(duration);

Serial.print(distanceCm);

Serial.print("CM");

Serial.println();

void checkLimit();

delay(100);

}

void checkLimit(){

if(distanceCm < limitCm){

digitalWrite(relay,HIGH);

}else{

digitalWrite(relay,LOW); }

}

long microsecondsToCm(long microseconds)

{

return microseconds / 29 / 2;

}

THE INO FILE IS GIVEN BELOW FOR EASE(YOU CAN DOWNLOAD IT)

Step 3: UPLOADING THE PROGRAM

1. INSERT YOUR ARDUINO IN YOUR LAPTOP

2.A POP UP WILL COME WHICH WILL SHOW SOMETHING LIKE ...................ARDUINO ON COM3 OR COM1

3. REMEMBER THE COM NUMBER

4.NOW OPEN ARDUINO WINDOW AND FOLLOW THE STEP TOOLS>ARDUINO>SELECT ARDUINO V YOU ARE USING EG. ARDUINO NANO && DO

TOOLS>PORT>SELECT THE COM NUMBER REMEMBERED BY YOU!

5. ON LEFT SIDE OF COMPILE BUTTON THERE IS A UPLOAD ICON CLICK IT

UpLoAdInG..............................

Step 4: CONNECTIONS

1. OPEN YOUR LAMP AND TAKE ANY WIRE ARISING FROM THE BATTERY OF IT EITHER + OR - . I PREFER +

2. CUT IT

3. CONNECT ONE END OF WIRE TO RELAY NORMALLY OPEN PIN

4. AND CONNECT ANOTHER TO THE RELAY COMMON PIN

5. WHEN YOU WILL NOW SWITCH ON YOUR LAMP IT WOULDN'T GLOW

6. CONNECT THE RELAY POWER PINS IN YOUR ARDUINO THROUGH WIRE AT THE PIN 4 OF ARDUINO

7.CONNECT +&- OF HC-SR04 TO +5 VOLT PIN OF ARDUINO AND - TO GND RESPECTIVELY

8.CONNECT THE TRIG PIN OF HC-SR04 TO PIN 2 OF ARDUINO AND ECHO PIN TO PIN 3 OF ARDUINO

ALL CONNECTIONS MADE BY JUMPER WIRE AND FEMALE HEADER

Step 5: FINAL TOUCH

1.PUT YOUR HC-SR04 IN THE CHAIR (refer picture)

2.POWER YOUR ARDUINO

3.I REFER YOU TO PUT A SWITCH WHILE POWERING YOUR ARDUNO

NOW WHEN YOU WILL SIT ON YOUR CHAIR THE LAMP WILL ILLUMINATE

THANK YOU

BYE

PLS VOTE

Step 6: PROS AND COS

PROS

1.RIGHT SITTING POSTURES //sdauiudiiasdiaduiaud9a8ud98u

2.SAVES BATTERY

3. AUTOMATIC

4. USES ARDUINO UNO HENCE NO NEED FOR EXTRA IC'S

5.SIMPLE TO MAKE

COS

1. DELICATE(IF I USE TO OUCH MY ARDUINO IT SHUTS DOWN AND I HAVE TO RESTART IT)

2. NOT WIRELESS

Home Automation

Participated in the
Home Automation

Bedroom Contest

Participated in the
Bedroom Contest

Metal Contest

Participated in the
Metal Contest

Be the First to Share

    Recommendations

    • For the Home Contest

      For the Home Contest
    • Big and Small Contest

      Big and Small Contest
    • Game Design: Student Design Challenge

      Game Design: Student Design Challenge

    13 Comments

    0
    Chitlange Sahas
    Chitlange Sahas

    6 years ago

    hey aditya.!
    please turn off your caps lock off. the button to the left of "a".
    it seems you are shouting all the way throughout.
    Normal sentances are far more appealing to read.
    Keep learning.
    happy making:)

    0
    Aditya Tripathi
    Aditya Tripathi

    Reply 6 years ago

    sorryfir the aame but it was my first i'ble now I hv improved

    0
    Saiyam
    Saiyam

    7 years ago

    There is a key called caps lock which I think you have accidentally left on :D

    0
    Saiyam
    Saiyam

    Reply 7 years ago

    Oh, but this is to tell you that doesn't look good. I really mean that. Most of the instructables you see always have text in lower case format. Keep that in mind next time.

    Also your cover photo does not describe the project but yourself. The guys at instructables always say that the cover has to be informative and descriptive.

    0
    chandubandara
    chandubandara

    Reply 7 years ago on Introduction

    Good project! You got my vote too, use sentence case (the normal way we write; first letter being capital of the sentence and the rest lowercase) in the future instructables, it is aesthetically pleasing to the reader that way...

    Use all Caps when you need to emphasize on some particular thing. You can make it bold too! Happy Making!

    0
    Aditya Tripathi
    Aditya Tripathi

    Reply 7 years ago

    tysm I will remember it in future

    0
    RxTx
    RxTx

    7 years ago

    If u live in NCR PLEASE tell me where do u buy electronic stuff my only support is eBay right now

    0
    RxTx
    RxTx

    7 years ago

    Another thing please don't upload ur selfies too

    0
    RxTx
    RxTx

    7 years ago

    Good thing bro but could use a few modifications though.U are Indian I guess.