Introduction: Sensitive Touch Lamp
Hi everyone, first of all sorry for the poor english wich will follow.
for the lamp's design, i borrow the inspiration from this instructable by Wildman Project
https://www.instructables.com/id/How-to-Make-a-Lamp...
He did all the cuts with a cnc ( you can find the files with the link), i haven't finish my own cnc so i did the differents decorations patterns with a manual scroll saw and i use the cnc like a milling machine (with a keyboard) to make the base of the lamp.
Compare to the original tutorial, i add a sensitive touch light switch based on a atmega 328p.
You can see the result in the short video below.
Step 1: Electronic Parts: What You Need and General Explanation
What you need :
- An atmega chip, i used an atmega328p-pu (i already had it, but you can take a smaller one, your choice)
like this one :
https://www.aliexpress.com/item/1PCS-ATMEGA328P-PU...
- DC-DC Adjustable Step Down Power Supply
like the one below :
https://www.aliexpress.com/item/New-Arrival-LM2596...
- A transistor arrays (not sure about the terms) ULN2003, same things than the chips i used it because i had one, but you can use 3 separates transistors.
but i use this one:
https://www.aliexpress.com/item/10PCS-LOT-ULN2003A...
- A resistance, i used a 1 Mohm to do the capacitive switch
- You'll need some leds, i used 3 strips of 18 SMD3528 and the 12v adapter to power it.
- You will need also an arduino (uno, duemilanove etc...) to programm the atmega chip.
I won't explain the programming of the atmega, you will find the process on this page in the arduino official website.
https://www.arduino.cc/en/Tutorial/ArduinoToBreadb...
How it works :
In a few word, you need to power supply the atmega chip in 3v after reducing the voltage from the adapter with the step-down from 12v to 3v, then two pins of the chip will be use to do the capacitive touch switch,and 3 atmega pins will be wired to the ULN2003 to switch-on the 12v power supply from a 3v atmega signal and turn on the led strips one by one.
Step 2: The Wiring : Power Supply the Atmega Chip
you'll need to power the atmega chip from the 12v power supply passing by the step-down module to power the atmega chip in 3v only.
Don't forgive to adjust the step-down with a screwdriver to 3v
Important!!! like describe on the picture, you need also to wire the pin vcc 7 to the pin arev vcc 20 on the Atmega chip.
Step 3: The Wiring : Wiring the Atmega to the ULN2003
- you need to connect the pins 11, 12 and 13 on the atmega (corresponding to the digital pin 5, 6 and 7 on the arduino uno and in the sketch software) to the pins 1, 2 and 3 on the ULN2003 (no matter the order)
- wire the ground from atmega to the ground of the ULN2003 (pin 8)
- wire the ground directly from the power supply (before the step-down) to the ground arduino/ULN2003, all the parts of the assembly needs a common ground
Step 4: The Wiring : Connect the Led Strip to the ULN2003 and to the Power Supply
Now you have to connect the ground of the led-strips to the pins OUT 1, 2 and 3 of the ULN2003 and the positive pins of the led-strip to the vcc of your 12v adapter (before the step-down, you need 12v for the leds)
-I used a led-strip, so there are some resistances already solder inside it, if you use single led do what it needs to keep it alive...
-i used 3 strips of 18 led, if you need more, read the datasheet of the ULN to see what is max current it can dissipate (heat) and adjust it to your assembly or change for biggest transistors.
Step 5: Capacitive Sensor, What Is It
It is too difficult for me to explain it in english, so i copy the DangerousTim explanation from this instructable :
https://www.instructables.com/id/How-To-Use-Touch-S...
Capacitive Sensing:
Capacitive touch sensing is a way of human touch sensing, that requires little or no force to activate. It may be used to sense human touch through more than a quarter of an inch of plastic, wood, ceramic or other insulating material (not any kind of metal though), enabling the sensor to be completely visually concealed.
Why Capacitive touch?
Each touch sensor requires only one wire connected to it.
Can be concealed under any nonmetallic mmaterial.
Can be easily used in place of a button. Can detect a hand from a few inches away, if required.
Very inexpensive.
How does it work?
The sensor plate and your body forms a capacitor. We know that a capacitor stores charge. The more its capacitance, the more charge it can store.
The capacitance of this capacitive touch sensor depends on how close your hand is to the plate.
What does the Arduino do?
Basically the arduino measures how much time the capacitor (i.e the touch sensor) takes to charge, giving it an estimate of the capacitance. The capacitance may be very small, nevertheless the Arduino measures it with accuracy. One way of using capacitive touch in a project is to use the CapSense library. For the Capsense library, the arduino uses one send pin and any number of receive pins required. A receive pin is connected to the send pin via a medium to high value resistor.
In his instructable DangerousTim use the Capsense library.
Here we will use the CapacitiveSensor library originally written by Paul Badger and now maintained by Paul Stoffregen.
Step 6: The Wiring : Wire the Capacitive Switch
Now to make the capacitive switch, you need to wire a 1Mohm resistance to the pin 15 (digital pin 9 on arduino sketch) and to the pin 19 (digital pin 13 on arduino sketch) of the atmega
then to solder a long wire to the resitance/pin19 to make the "antenna" (not really the good term) which will be used to switch on/off the led strip.
In this assembly, there will be 4 step to turn on/off the light.
one touch ( or hang over depending the settings) = turn on 1 led strip
second touch = turn on 2 led strips
third touch = turn on 3 led strips
fourth touch = turn off all the led strips
Now it's ok for the wiring, we just have now to upload the sketch inside the atmega.
Step 7: Programming the Atmega 328p-pu
Here is the sketch we have to upload in the atmega, refer to the link above to know the process to do it.
I'm not really good to write sketch, so i took some pieces here and there, i try and retry and finally it works.
So better "arduiner" than me, feel free and very welcome to give us better way to write this.
You will find the library here
#include <CapacitiveSensor.h> CapacitiveSensor capteurCapa = CapacitiveSensor(9,13); int seuilDeclenchement = 650; const int grp1 = 5; const int grp2 = 6; const int grp3 = 7; int etatgrp1; int etatgrp2; int etatgrp3; void setup() { Serial.begin(9600); pinMode(grp1, OUTPUT); pinMode(grp2, OUTPUT); pinMode(grp3, OUTPUT); } void loop() { etatgrp1 = digitalRead(grp1); etatgrp2 = digitalRead(grp2); etatgrp3 = digitalRead(grp3); long mesureCapteur = capteurCapa.capacitiveSensor(30); Serial.print("Mesure : "); Serial.println(mesureCapteur); if ((mesureCapteur > seuilDeclenchement) && (etatgrp1 == LOW) && (etatgrp2 == LOW) && (etatgrp3 == LOW)) { digitalWrite(grp1, HIGH); delay(200); } if ((mesureCapteur > seuilDeclenchement) && (etatgrp1 == HIGH) && (etatgrp2 == LOW) && (etatgrp3 == LOW)) { digitalWrite(grp2, HIGH); delay(200); } if ((mesureCapteur > seuilDeclenchement) && (etatgrp1 == HIGH) && (etatgrp2 == HIGH) && (etatgrp3 == LOW)) { digitalWrite(grp3, HIGH); delay(200); } if ((mesureCapteur > seuilDeclenchement) && (etatgrp1 == HIGH) && (etatgrp2 == HIGH) && (etatgrp3 == HIGH)) { digitalWrite(grp1, LOW); digitalWrite(grp2, LOW); digitalWrite(grp3, LOW); delay(200); } delay(10); }
Feel free to test different settings
seuilDeclenchement = 650, this one allow you to play with the sensitivity of the assembly, if you put a low value, just approaching your hand will trigger the signal and light on a led strip.
With very low value just beeing in the area of the "antenna" wire will trigger it, so try and find the setting for your project.
You can also change the value of the resistance to change that sensitivity.
You can also connect the "antenna" wire to an aluminium sheet like i did to allow to touch all the surface of the lamp to turn it on (have a look on the picture in the beginning of this tutorial).
Ok, I think we're good now, it's my first instructable so be indulgent and don't hesitate to vote for it
Thank you