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)

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:

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 =)


esplonky made it!(author)2009-02-16

i'm obsessed with the beatles!

rac83 made it!(author)2008-11-10

Hy First, great project ;-) You used the CCS compiler right? I'm just trying to rewrite the code to SDCC but I'm little bit hanging in the air because this is my first attemp to program a PIC. Does someone here have some example codes for SDCC just to see how to make the skeleton and using I/O Pins...???

GorillazMiko made it!(author)2008-08-10

Cool, but too hard for me! :P

Shifrin made it!(author)2008-01-04

This is cool! but can you find a clearer video?

Proteus made it!(author)2008-01-04

Sure! now that I've finally bought a decent camera for Christmas, I can =)!
I'm kinda busy this week, but I'll put it in my TODO list !

Thanks for the feedback!

Shifrin made it!(author)2008-01-04

Great! Thanks!

Myrddin made it!(author)2007-04-17

How about a good image here, OK?? This ones crappy...

Proteus made it!(author)2007-04-17

Do you mean the circuit schematics?
It`s scaled down by the site, most images on Instructables are actually much larger than they appear to be =D, click on the "i" box on the upper left of it, or go to this LINK:
then select ORIGINAL SIZE... its actually pretty big nice (3508x2480) 329 KB image =]

Proteus made it!(author)2007-02-14

If anything was left unclear ,just ask and I'll explain it better =]

daenris made it!(author)2007-02-14

So how did you manage to make the contacts on the plastic?

Proteus made it!(author)2007-02-15

=D I'll get my Digital Camera back tonight (someone borrowed it) then I'll take some pictures/make a small video on how to do that

T3h_Muffinator made it!(author)2007-02-14

AWESOME! Although, you get -1 man point for getting pushed around from your girlfriend, but +10 man points for actually having a girlfriend..... Man, it's Valentine's day and I don't have anyone... sigh.....

About This Instructable




Bio: Engineer graduated @ , Embedded Software Engineer @ , and all around nice guy =]
More by Proteus:The ChargerLight: WallCharge your USB devices with style"TouchTimer" EggLight (valentine's gift) 8 Bit Serial Digital to Analog (5v range) Converter for microcontrollers (when TTL and Resistors is all you've got)
Add instructable to: