Android Phone Controlled Lamp

by CallMeSwal in Workshop > Lighting

7824 Views, 101 Favorites, 0 Comments

Android Phone Controlled Lamp

RC Lamp
IMG_20150523_210252.jpg
IMG_20150523_210238.jpg
IMG_20150523_210141.jpg
IMG_20150523_004928.jpg
Screenshot_2015-05-25-03-06-27.png
Screenshot_2015-05-25-03-06-35.png
Screenshot_2015-05-25-03-06-21.png

In this Instructable we're going to make a lamp that we can control with an android phone. Using an app, we'll be able to adjust the brightness of the lamp.

How It Works

IMG_0039.JPG
IMG_20150524_002349[1].jpg
IMG_0037.JPG

The brightness of the lamp is regulated by a simple dimmer switch. The switch is rotated autonomously using a basic servo, that is controlled by an arduino. The arduino rotates the servo in a particular fashion when it receives a certain command from the android phone. The commands are sent via bluetooth. The phone app sends a command whenever the user adjusts the brightness of the phone, either verbally or with text.

*All the code has already been written and is available throughout the Instructable.

Materials and Tools

IMG_20150522_184015.jpg
IMG_0005.JPG

Materials

  • Desk Lamp
  • Dimmer Switch //controls brightness of lamp, available at any hardware store
  • Wire Box //box that encloses switch contents, available at any hardware store
  • Switch Plate
  • 3 screw nuts //Generally comes packaged with dimmer switch
  • Wire
  • Breadboard
  • Arduino Uno
  • Servo
  • Bluetooth Module //I'm using a bluetooth mate
  • 9v Battery and Battery Pack //You only need one battery pack to power the servo, but I'm using a second one to power the arduino
  • Android Phone

Tools

  • Glue Gun
  • Wire Strippers
  • Soldering Iron
  • Electrical Tape

Phone Software

Protocoder needs to be installed on the android phone. Protocoder is a coding environment that can run javascript programs; like the one we'll use to control the lamp. You can download the app from this link.

http://www.protocoder.org/

Install the Dimmer Switch

IMG_0006.JPG
IMG_0008.JPG

This part of the project is going to take a few steps to get through. Proceed with caution. The installation is straight forwards but we don't want to take any risks.

Start off by unplugging the lamp. Make sure the lamp is unplugged until the installation is over!

Now, cut the lamp cord in two. I recommend cutting the wire near the half way point.

Strip the Lamp Cord Wires

IMG_0009.JPG

Strip all 4 wires of the lamp chord.

Snip the Neutral Wire From Dimmer Switch

IMG_0010.JPG
IMG_0011.JPG

We won't need to use the neutral wire on the dimmer switch. So I recommend snipping the exposed portion of the neutral wire as a precaution.

Connect Lamp Cord Wire to Dimmer Switch

IMG_0015.JPG
IMG_0014.JPG
IMG_0012.JPG
IMG_0018.JPG
IMG_0020.JPG
IMG_0022.JPG
IMG_0024.JPG
IMG_0025.JPG

We have to identify the side of the cord that is neutral and the side of the cord that is hot. The neutral side will tend to have ribbing or ridges. I double checked by opening up the lamp. You can triple check with a multimeter. The neutral side will be connected to a white wire and the hot side will connected to a black wire. After you have identified the hot and neutral sides, label them to ensure there will be no errors.

After you label the wires, run them through the sides of the wire box.

Connect the neutral wires together with a screw nut and connect the each of the hot wires to a black wire on the dimmer switch, also with a screw nut. Wrap the screw nuts with electrical tape afterwards.

Screw Switch and Lid in Place

IMG_0031.JPG
IMG_0032.JPG
IMG_0035.JPG
IMG_0036.JPG
IMG_0037.JPG

Stuff the wires in the wire box and then screw the switch and lid in place, with the provided hardware.

Congratulations! You have successfully installed a dimmer switch on your lamp. Plug the lamp into a socket and adjust the brightness by rotating the switch dial.

Attach Servo, 9v Battery Packs, Breadboard and Arduino

IMG_0039.JPG
IMG_0047.JPG
IMG_0051.JPG

Hot glue the servo horn to the centre of the dial.

Secure the servo to the switch plate in any way that you would like. I bolted one section of the servo to the switch plate.

I know it doesn't look very pretty but it was quick to set up :)

Afterwards, attach the arduino to the wire box. I kept my arduino in place with an elastic.

Glue your battery pack, for the servo, to the box and stick your breadboard on as well.

I glued on a second battery pack to power the arduino.

Grab the bluetooth module and stick it into the breadboard.

Wire the Servo and Bluetooth Module Up

schematic.PNG

Wire up the servo and bluetooth module.

Make sure the RX port of the bluetooth module is connected to the TX port of the arduino. And that the TX port of the bluetooth module is connected to the RX port of the arduino.

Ensure the servo is connected to port 8 of the arduino.

Upload Arduino Code

Upload the code to your arduino board.

Install Protocoder

Screenshot 2015-05-16 14.17.08.png

Install Protocoder on your android phone.

http://www.protocoder.org/#download

Upload Code to Phone

Screenshot_2015-05-25-03-06-31.png
Screenshot_2015-05-25-03-06-35.png
Screenshot_2015-05-25-03-05-56.png

Make a new program in Protocoder and paste the contents of phoneCode.js into the program.

Downloads

Try It Out!

IMG_20150523_210225.jpg
IMG_20150523_210252.jpg
RC Lamp

Congratulations!

You have finished making an RC Lamp.

Power your arduino and then run the app on your phone. Tap Connect To Bluetooth and select your bluetooth module. Wait for the module to connect, generally the module will have an LED indicator. Enter a value from 0-180 and watch the lamp adjust. Try using the voice control method afterwards. Tap Inc/Dec and then say either Increase, Decrease, or Stop. Saying increase will brighten the lamp. Saying decrease will dim the lamp. And saying stop will stop the servo.

Future

You may notice that if you send an 'a' or 't' over the serial port, the lamp will start flashing. In the future, I was hoping to get the lamp to flash every time the user received a text or set an alarm. If you guys come up with any ideas on how to improve the lamp, I would love to hear them.