Capacitive touch Mood light using Arduino

Arduino Touch Mood light (3)

This instructable is a quick write-up of my experience creating a multifunctional moodlight. Some basic knowledge of electronic circuits is expected. The project has not yet finished, some adding functionality  and tweaking has to be done but it is already functional. If you guys are enthousiast about this instructable I will update it.

Arduino Touch Mood light (3)

At the heart of the system is an Arduino. It will process the input from USB or each of the Capacitive touch inputs and control the RGB light.
This instructable is split into three sections:
– The capacitive touch section covers the invisible input buttons
– The moodlight section covers the controlling of the moodlight
– The ambilight section covers input by serial port, processing RGB values generated by a computer program to control the lights.

Disclaimer: Electronics can be dangerous, you yourself are responsible for any damage done. Some code is collected from forums and might not contain the name of its owner. Please let me know and I’ll add your name.

Step 1: Item list

The following components are needed for this instructable:

– Arduino+USB cable
– Breadboard
– Computer power supply
– 3x RGB strips, check out
– 3x TIP120 FETs, like
– A bunch of resistors (6* 10 kiloOhm, 3 * 2 megaOhm)
– A lot of wire.
– Tools

Capacitive touch
– Metal rings for groundplates
– Copper wire or plate
– Something to build it into (like a bookshelf:)

Step 2: Capacitive Touch – Basics & Circuit

Since I was painting my bookshelfs, I had the oppurtunity to ‘upgrade’ them as well. I wanted to control the moodlight by means of invisible touch. At first, my plan was to use a dedicated IC for this (like the Atmel QT240). But then I stumbled upon a page explaining that the Arduino can emulate a capacitive sensor by software.

The electronic circuit can be found in the picture, the sensor is a spiralled copper wire (only one is shown for simplicity). Sensitivity is controlled by the resistors found before every pin. They can range from 1 MegaOhm (absolute touch) to 40 MegaOhm (12-24 inch away) depending on if absolute or near touch is needed (I ended up using 2M Ohm resistors). Experiment with the values until the sensor behaves like desired. It is a good idea to install some conducting surface (seperated by a thin non-conducting piece) connected to the circuits’ ground at the back of each spiral. This way the sensors will be more stable and less influenced by noise.

Some more pictures about installing the sensors in a bookshelf. A plug is installed as well for easy connection with the circuit later on. Filler is used to conceal everything, and after that they are ready to be painted.

Step 3: Capacitive Touch – Code & Testing

The following source code can be used on the Arduino for debugging, check the values with the arduino serial monitor. Six values are generated. The first is a measure of the performance of the system. The second to sixth are the sensed values on every pin. The values should rise when nearing your finger. If not, check for bad connections and interference. The resistor values can be changed to determine sensitivity. By implementing an if-then structure which is activated at a certain logical treshold, a switch can be made. This will be used in the final arduino code.Arduino touch Mood light circuit (3)

More information, suggested to read:

— Arduino CapTouch Debugging Code —

void setup()  {
CapSense   cs_2_3 = CapSense(2,4);        // 10M resistor between pins 2 & 4, pin 4 is sensor pin, add wire, foil
CapSense   cs_2_4 = CapSense(2,7);        // 10M resistor between pins 2 & 7, pin 7 is sensor pin, add wire, foil
CapSense   cs_2_5 = CapSense(2,8);        // 10M resistor between pins 2 & 8, pin 8 is sensor pin, add wire, foil
CapSense   cs_2_6 = CapSense(2,12);        // 10M resistor between pins 2 & 12, pin 12 is sensor pin, add wire, foil
CapSense   cs_2_7 = CapSense(2,13);        // 10M resistor between pins 2 & 13, pin 13 is sensor pin, add wire, foil

void setup()


void loop()
long start = millis();
long total1 =  cs_2_3.capSense(30);
long total2 =  cs_2_4.capSense(30);
long total3 =  cs_2_5.capSense(30);
long total4 =  cs_2_6.capSense(30);
long total5 =  cs_2_7.capSense(30);

Serial.print(millis() – start);        // check on performance in milliseconds
Serial.print(“\t”);                    // tab character for debug windown spacing

Serial.print(total1);                  // print sensor output 1
Serial.print(total2);                  // print sensor output 2
Serial.print(total3);                // print sensor output 3
Serial.print(total4);                // print sensor output 4
Serial.println(total5);                // print sensor output 5

delay(10);                             // arbitrary delay to limit data to serial port

Step 4: Mood Light – Basics & Circuit

Now it is time to build the output part of the system. The arduino’s PWM pins will be used to control each colour. PWM means Pulse Width Modulation, by switching a pin on and off very quickly the leds will be dimmed from 0 to 255. Every pin will be amplified by a FET. For now, the system has only one channel per color, meaning that all RGB strips will  be controlled at once and 3 PWM pins are needed (one for every colour). In the future I want to be able to control each of my four RGB strips. That means 4*3=12 PWM pins (and probably an Arduino Mega).

Ok, time for some schematics! This (see picture) is a basic representation of the circuit (will make a nicer one soon). The capacitive sensors are included as well (green part). Basically there are three components that have to be explained:

This is the amplifier I was talking about. It has a Gate, a Source and a Drain. It amplifies the senses a small current on the gate (connected to the Arduino) and opens the way for the RGB strip that is driven on 12 volts. Source should be on +12V, drain on GND (Ground). Check the specifcations sheet of your FET for exact pinout. Every RGB channel should be positioned before its own FET. In this sense, it is acting like an Arduino controlled switch.

Read more: Capacitive touch Mood light using Arduino

Leave a Comment

Your email address will not be published. Required fields are marked *