Introduction: AUTOMATED DESK LAMP.....(with ARDUINO and HC-SR04)

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

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

Comments

author
Chitlange Sahas (author)2016-08-06

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:)

author

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

author
Saiyam (author)2015-06-29

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

author
Aditya Tripathi (author)Saiyam2015-06-29

Unfortunately i have to say that i had left it intentionally

author
Saiyam (author)Aditya Tripathi2015-06-30

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.

author
Aditya Tripathi (author)Saiyam2015-07-01

Thanks

author

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!

author

tysm I will remember it in future

author
nullf0x (author)2015-07-04

Great! I voted for U!

author
Sheldy123 (author)2015-07-02

Great job!

You got my vote:)

author
RxTx (author)2015-06-27

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

author
RxTx (author)2015-06-27

Another thing please don't upload ur selfies too

author
RxTx (author)2015-06-27

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

About This Instructable

1,541views

14favorites

License:

Bio: I love all things related to electronics . Follow me for awesome instructables. Science lover. Chemistry hater. Arduino ,linkit one, pro mini etc. familiar with these ... More »
More by Aditya Tripathi:Go Green Powerbank W/ Speaker and LEDsLogical ClockStalker Guard
Add instructable to: