Nav

Make a Light Switch with Electric Paint

For the experts out there. Follow this tutorial to paint your own light switch using Electric Paint.

This is one of the most exciting tutorials we’ve put up yet. We’re going to show you how to use a pad of Bare Paint as a capacitance sensor to trigger a mains relay. To do this we are going to be using the code below and a cool relay shield from Ciseco on top of an Arduino Uno. The shield will switch up to 10 amps at 204V AC. It is important to note that this tutorial involves mains electricity and is POTENTIALLY DANGEROUS. If you’re not comfortable working with mains electricity, then you should stop here and get help from someone who is qualified. Once you’ve gathered your materials and are ready to build, the first step will be setting up the shield. You can now do this with the Touch Board too!

Download the Cap Sense Code here

Download the Arduino Library here

Update 1: If you have a Touch Board go to the Touch Board Light Switch tutorial.

Update 2: The relay shield we suggest in this tutorial has been discontinued. We are searching for a suitable replacement, but in the meanwhile this tutorial remains for inspiration. It is possible to adapt the instructions here to fit other relay shields.

Experiments in screen printing and linking information onto paper graphics

Paper Apps and Invites

Learn how to make a simple capacitance sensor using a pad of Electric Paint, an Arduino and a resistor.

Building a Capacitive Proximity Sensor using Electric Paint

Materials

To begin you will need:

Electric Paint (10ml or 50ml)
Arduino Uno (or similar)
Ciseco 10 Amp Relay Shield
Jump Wires
USB Cable
Resistors
Terminal Blocks
Project Box
Mains Cable
Plug
Sockets

These components can be sourced from: Farnell, Jameco, Sparkfun or Maplin

Step 1

Setting up the shield

We are using a shield produced by Ciseco. It’s got a 240 V AC 10 amp relay so its pretty tough! Its shaped to fit any standard Arduino or clone and is well laid out. We are going to be adding a couple of little pieces to the shield to work with the code that we’ll be uploading later. First we want to place our terminal blocks on pin 4 and pin 2. The block spacing is such that it fits directly into every other pin. The pins on the terminal blocks might be a bit big, so you may want to make them a bit thinner with a file or sandpaper. Once you’ve got the terminal blocks on the shield, solder them in.

Step 2

After the terminal blocks we need to add two additional wires, one for the signal to trigger the relay and the other to ground the Arduino. The signal wire (red in these photos) goes from pin 13 to the whole marked “input” on the shield.

Once you’ve soldered the input wire, take a second wire and solder it to one of the ground pins (the brown wire in these photos). The other side of this wire will be placed in the “earth” terminal block of the relay on the input side (see photo below).

Now that we have the basics of the shield prepared you can put it on top of your Arduino.

Step 3

Next we will add the wire to pin 2 to connect to our pad of paint and a resistor between pins 2 and 4. The size of this resistor will affect the sensitivity of your sensor, so you may want to play with other sizes to get the best effect.

Step 4

Wiring the Shield

Wiring the Sheild

Now that your shield and Arduino are complete, we move onto wiring up the mains input and output from the shield. This portion of the tutorial is POTENTIALLY DANGEROUS. If you are not experienced and are not comfortable working with mains electricity do not proceed. Get help from someone who is competent working with mains electricity.

We will first wire the output side. Using a section of 3-core mains cable, strip the insulation back to expose the ends. Wire the cable to the relay’s terminal blocks as indicated, noting Live, Neutral and Earth. Secure the cable to the shield using cable ties. Wire the other side of the output cable to a socket, again, making sure that you have appropriately placed the cables.

Next, we are going to wire the mains input to the relay. It should go without saying, but NOTHING SHOULD BE PLUGGED IN at this point. Strip the 3 core cable and wire the Live, Neutral and Earth to the appropriate places on the relay. Secure the cable to the board with a cable tie. On the other end of the cable, we are going to wire a plug, again watching that each cable is wired correctly.

You now have a mains input to your relay, an output to a socket and a shield mounted on an Arduino, cool! Its time to put all of this project into a box so that there is no risk of making any physical contact with the Arduino or the shield. This is a safety measure. Make sure that the box is secure and NOT CONDUCTIVE (i.e. don’t use a metal box!). Triple check your connections and make sure that the cables can get in and out of the box with no restriction or binding and that you leave space for a USB cable so that you can program the Arduino.

You’ll want to cut some holes to route the wires through as seen in the image below.

Step 5

Make sure that you strain relieve any wires going out of the box (I just used some cable ties below). This way, if anyone pulls on the wires, they will only be pulling against a cable tie and won’t compromise the shield itself.

Step 6

I decided to mount the socket into the cool transparent lid of my enclosure. I cut the lid to fit the back side of the socket and then mounted it with the provided machine screws. I decided to mount the socket into the box itself so that this would exisit as a standalone unit, but you could run the mains cable out of the box and attach it to a remote socket as well. If you decide to use a remote socket, make sure that it is also properly enclosed.

Step 7

Painting a Sensor

You’ll need to a paint a pad of Electric Paint to work as a capacitive sensor as we did in this tutorial here. The size and shape of the paint pad aren’t crucially important (though they may affect the values that you receive into the serial port). We decided to paint a ‘light switch’ onto our wall as seen in the photo below.

Here we used a magnet to connect to the paint so that it would be easy for us to detach wires when not in use. Because the magnet is metallic, its conductive so we glued it to the wall (using our paint) and then painted a line directly onto. This way we have an electrical connection between the pad that we touch and the wire that is connected to our box.

Step 8

Downloads

Download the Cap Sense Code and the Arduino Library

Links

Step 9

Programming

Now that everything is in the box, we’re going to program the Arduino. Make sure again that nothing is plugged into the mains, and never reprogram the Arduino while it is attached to the mains as your computer might get a nasty shock. Make sure that you have downloaded and installed the latest version of Arduino as well as the CapSense library and the light switch code. Links to all three of these can be found at the bottom of the page. Install the Capsense library, plug the Arduino into the computer and upload the light switch code. For more information on how to do this, make sure to check out our Capacitance Sensor Tutorial.

Now that the software is uploaded, its time to test our sensor. Leaving the arduino connected to the computer, connect the wire to the pad of paint. Touching the pad of paint should trigger the relay. If so, you’ll hear a “click.” If you don’t the first thing to to would be to check the numbers coming into the serial port through the Arduino environment.

Within the code there is a variable called ” threshold.” In order for your hand to trigger the relay, the number coming to the serial port needs to be higher than the threshold. I’ve set the threshold at 390 (but this is a somewhat arbitrary number that is specific to my pad of paint and my chosen resistor). Lets say that without touching the paint, the number to the serial port reads 500, when touching it, it reads 5000. Your threshold number should be somewhere between these two (say 1500). In general, the higher the threshold, in comparison to your two readings, the less sensitive and slower the switch will be. If manipulating the threshold doesn’t work, try playing with the resistor and seeing if you get values which are more successful.

Once you have tested your switch and the relay is tripping reliably, you can finish setting up your light. Since the Arduino requires DC power to switch the relay, we’re going to use a small mains AC-DC inverter with a USB port. Plug in the USB cable between the inverter and the Ardunio. Plug the mains input into the mains, and plug your light into the output. Hopefully touching the pad of Bare Paint will trigger the light!

See the top of this page for download links to the Cap Sense Code and Arduino Library.

Step 10

Suggested Tutorials

Experiments in screen printing and linking information onto paper graphics

Paper Apps and Invites

Learn how to make a simple capacitance sensor using a pad of Electric Paint, an Arduino and a resistor.

Building a Capacitive Proximity Sensor using Electric Paint

Categories

Bare Conductive

Electric Paint Projects

Date Posted

2011/12/07

Rating

0.00 avg. rating (0% score) - 0 votes