Position: Index > Control Circuit >

PIC12F675 8-Pin, Flash-Based 8-Bit CMOS Microcontroller App

2015-02-28 07:18  
Declaration:We aim to transmit more information by carrying articles . We will delete it soon, if we are involved in the problems of article content ,copyright or other problems.

 

This is a project to have some nice lights on the door at christmas time. It uses battery power, it's hard to fit a wire onto the door. A PIC12F675 is used to create av PWM and act as a dark activated switch.The schematic:PIC12F675 The Leds used are 6 warm-whites with 120 degress angle from Molelectric ( http://www.molectric.com/product_info.php?cPath=22_50&products_id=382 . The power source is 3 GP2500 NiMH batteries, last year the leds lit for 31 days. The code for the PIC is written in mikroC:/*Led PWMPHermansson 2006For mikroC compiler for PIC, www.mikroelektronika.co.yu*/char counter;void interrupt(){counter ++; // increment counterTMR0 = 254;INTCON = 0x20; // set T0IE, clear T0IF . h20=100000}void main() {OPTION_REG = 0x84; // TMR0 prescalerTRISIO = 0b00010000; //GP4 in, GP5 out.GPIO = 0xFF; // initialize gpiocounter = 0; // set counterTMR0 = 254; // set timer0INTCON = 0xA0; //TMRO interrupt enabled 80=10000000-> T0IE offANSEL=0;do{ // Loopif (counter > 200) // Counts from 0 to 255 and then flips to 0// Counter > x sets pwm period, lower value = brighter led.{if ( GPIO.GPIO4 == 1 ){GPIO.GPIO5 = 1;}else{GPIO.GPIO5 = 0;}}else{GPIO.GPIO5 = 0;}} while(1);}