Introduction: "TouchTimer" EggLight (valentine's Gift)
Short description:
+High brightness microcontrolled LED light
+Touch Enabled (no buttons!) , the touch sensor will check it's inputs every 288ms to conserve power
+"Shutdown" TIMER : If the user holds the finger contacts for N seconds it will take N minutes for it to shutdown (or by touching it again )
+Estimated 60 days of battery life (15 min of use per day)
This is a Bedside Night Light I've built for my girlfriend:
+It had to be small
+Portable soft lighting for "stealth home navigation" at night
+It had to be COOL !
The Design:
ping-pong ball + generic_product_cap + capacitive_sensor_made_with_a_pic = EggLight !
Stuff needed :
- Ping-Pong ball
- Generic Product Cap
- PIC12F675 (any pic will do)
- A BC548 transistor (or similar)
- some standard resistor values: 100ohm , 1Kohm , 1Mohm
- 10000mcd led (When I have time I'll do the RGB version ;-)
- 2 CR2032 (button cell)
+High brightness microcontrolled LED light
+Touch Enabled (no buttons!) , the touch sensor will check it's inputs every 288ms to conserve power
+"Shutdown" TIMER : If the user holds the finger contacts for N seconds it will take N minutes for it to shutdown (or by touching it again )
+Estimated 60 days of battery life (15 min of use per day)
This is a Bedside Night Light I've built for my girlfriend:
+It had to be small
+Portable soft lighting for "stealth home navigation" at night
+It had to be COOL !
The Design:
ping-pong ball + generic_product_cap + capacitive_sensor_made_with_a_pic = EggLight !
Stuff needed :
- Ping-Pong ball
- Generic Product Cap
- PIC12F675 (any pic will do)
- A BC548 transistor (or similar)
- some standard resistor values: 100ohm , 1Kohm , 1Mohm
- 10000mcd led (When I have time I'll do the RGB version ;-)
- 2 CR2032 (button cell)
Step 1: The Design
The initial design was supposed to be like the first picture... but an hiperbolic surface isn't quite easy to DIY =/
So I switched to the EggFormat
By placing the batteries on the lower side of the cap and sanding a piece of it it will stand-up straight
Step 2: The Touch-Sensor
The Capacitive touch sensor itself is nothing more than... CODE =D (and some resistors)
You see, each Pin (well most of them anyway) in the PIC microcontroller can be programmed during runtime to be INPUT, OUTPUT(HIGH or LOW) or just to be FLOATING on a tri-state condition...
What you need to do is (look at the schematics so you'll understand)
+Put Pin on High (gp_0)
+Let it Float (gp_0)
+Wait some time and read it's value with same pin or another one (gp1)
if a person is holding his finger between the finger contacts the capacitance of the pin is greatly increased , this way the gap of time that the Pin will take to discharge (during float) will be much larger than normal operation (no finger)... now look at the code below using two pins:
You see, each Pin (well most of them anyway) in the PIC microcontroller can be programmed during runtime to be INPUT, OUTPUT(HIGH or LOW) or just to be FLOATING on a tri-state condition...
What you need to do is (look at the schematics so you'll understand)
+Put Pin on High (gp_0)
+Let it Float (gp_0)
+Wait some time and read it's value with same pin or another one (gp1)
if a person is holding his finger between the finger contacts the capacitance of the pin is greatly increased , this way the gap of time that the Pin will take to discharge (during float) will be much larger than normal operation (no finger)... now look at the code below using two pins:
int fingert; int check_finger(){ for(fingert=0;fingert<100;fingert++) //redundance (just to make sure) { output_high(PIN_A0); delay_us(10); output_float(PIN_A0); delay_us(500); if( input(PIN_A1) ) { return 1; } } return 0;}
Step 3: The Firmware
#include <12F675.h>#device adc=8#use delay (clock=4000000, RESTART_WDT)#fuses WDT,INTRC_IO, NOCPD, NOPROTECT, NOMCLR, PUT, NOBROWNOUT int t; // int finger; int fingert; int tottime; #define TEMPO 60 int check_finger(){ for(fingert=0;fingert<100;fingert++) { output_high(PIN_A0); delay_us(10); output_float(PIN_A0); delay_us(500); if( input(PIN_A1) ) { return 1; } } return 0;} int16 rampont,ramptime;int16 currenton; void rampon(int16 raisems) { set_timer1(0); for(ramptime = 1; ramptime < raisems; ramptime++) { currenton = (100*ramptime)/(raisems); set_timer1(0); while( get_timer1() < 1000 ) { for(rampont = 0 ;rampont < currenton ; rampont++) { output_high(PIN_A2); } for(rampont=rampont ;rampont < 100 ; rampont++) { output_low(PIN_A2); } restart_wdt(); } } } void rampoff(int16 raisems) { set_timer1(0); for(ramptime = 1; ramptime < raisems; ramptime++) { currenton = (100*ramptime)/(raisems); set_timer1(0); while( get_timer1() < 1000 ) { for(rampont = 0 ;rampont < currenton ; rampont++) { output_low(PIN_A2); } for(rampont=rampont ;rampont < 100 ; rampont++) { output_high(PIN_A2); } restart_wdt(); } } } int on; int tcount; int ttcount; void main() { setup_adc_ports(0); setup_adc(ADC_OFF);// setup_counters(RTCC_INTERNAL,WDT_288MS); setup_wdt (WDT_288MS); setup_timer_1 ( T1_INTERNAL | T1_DIV_BY_1 );// setup_timer_1 ( T1_DISABLED ); setup_comparator(NC_NC_NC_NC); setup_vref(FALSE); while(1) { restart_wdt(); delay_us(1); on =0 ;ttcount=0; while(check_finger()) { on =1; ttcount++; rampon(500); //output_high(PIN_A2); rampoff(500); if(ttcount >=15)break; } for(tcount = 0; tcount < ttcount;tcount++) { for(t=0;t<TEMPO && !check_finger() ;t++) { delay_ms(1000); } } if(on)rampoff(1000); output_low(PIN_A2); sleep(); // WDT WAKE UP MEANS PC+1 8-| } return; }
Step 4: The Circuit
Not much to say here...
I used two batteries cause the LED needed more than 3V for full polarization...
Check the Image
Step 5: Final Assembly
The tricks I used in order to fit the circuit inside the cap would require another instructable themselves (mainly the "how to make contacts on plastic")...
But I used a 16 pin DIP socket to assemble the whole circuit
It took me around 8 hours to conclude this project but with the firmware already done you can build this really fast =)