The solution to this was to make an LED strip to mount on the underside of the kitchen counter with a simple way of turning it on and off. Of course we can't make it that easy, lets use a microcontroller. I am using the PIC16F628A with a momentary push button. I didn't have any D flip flops or other digital logic readily available and I have a small stock of these microcontrollers. So we begin the development.
Code:
void main() {
TRISA = 0;
INTCON.B4 = 1; //Enables the RB0/INT external interrupt
INTCON.B7 = 0; //Global Interupt Enable bit | Disable all interrupts
OPTION_REG.B7 = 0; //PORTB pull-ups are enabled by individual port latch values
OPTION_REG.B6 = 0; //Interupt on falling edge of RB0/INT pin
PCON.B3 = 0; //INTOSC 48 kHz
do{
PORTA = 0b00000000;
while(PORTB.B0 == 0);
INTCON.B1 = 0; //Clear the interrupt so SLEEP will work.
asm SLEEP;
PORTA = 0b00000011;
while(PORTB.B0 == 0);
INTCON.B1 = 0; //Clear the interrupt so SLEEP will work.
asm SLEEP;
}while(1);
}
Using a home built PIC programmer, I was able to download the code from MikroC to the controller and have it toggle the LEDs using the small, easily hidden push button. The lever is so you can slide your finger along the bottom of the cabinet and hit the button without knowing exactly where it is.
These are the super bright white LEDs that I used for the project.
These LEDs are surface mount, but the width was just right for some speaker wire I had laying around. I was able to scrape off the insulation and solder the LEDs directly to the wire.
From there, I used a simple transistor connected to the microcontroller to turn power on and off to the LED wires.
The final result of the project. The LEDs were tacked with thumb tacks to the underside of the cabinet.
No comments:
Post a Comment