3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

"TouchTimer" EggLight (valentine's gift)

Step 3The 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; }
« Previous StepDownload PDFView All StepsNext Step »

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
4
Followers
4
Author:Proteus
Engineer graduated @ poli.usp.br , Embedded Software Engineer @ v2com.mobi , and all around nice guy =]