In this tutorial, i'll show you how to easily control the brightness of your lamp without having to touch anything!
This is a very simple project, and can easily be adjusted to will.
Step 1: Gathering the Parts
The parts needed are:
- Arduino Uno
- Dinstance sensor
- Jumper wires
- Socket dimmer
Step 2: Connecting the Parts
The next thing that we'll have to do, is connect everything.
I made a quick schematic, as seen above.
NOTE: Some distance sensors (like mine) have 2 signal ports (TRIG and ECHO)
Connect TRIG to digital 7 and ECHO to digital 6
Step 3: Attach the Servomotor to the Dimmer
As you can see, I attached it with tape.
This is not super stable, so you can best use hot glue or other methods.
Step 4: Transfer the Code to Your Arduino
I uploaded the code to this pastebin: http://pastebin.com/DkJkWc53
As you can see, i attached the TRIG of the distance sensor to digital 7, and ECHO to 6.
You can play around with the distances, and the values in which your lamp will increase and decrease in brightness.
Upload the code, and the device should work!
Step 5: Make a Nice Casing
Don't judge my woodcrafting skills, but this will keep everything nicely in place.
If you make a nice looking case, it will look pretty on your nightstand!