 |
 |
| View previous topic :: View next topic |
| Author |
Message |
Guest
|
|
Posted: Sat Nov 04, 2006 5:06 am |
|
|
| jecottrell Thanks again iam trying to do two things with 1 push button and to change status until next action let's say 1 push for make the led on and stay not to change then 1 push to set it off and so.. |
|
 |
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Sat Nov 04, 2006 9:39 am |
|
|
| Code: |
#include <16F876A.h>
#fuses HS,NOWDT
#use delay(clock=20000000)
#use fast_io(b)
#use fast_io(c)
#define use_portb_lcd
#include <LCD.c>
#define Led_ON output_low(PIN_A1)
#define Led_OFF output_high(PIN_A1)
int8 toggle;
void main()
{
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_spi(FALSE);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
lcd_init();
printf(lcd_putc,"\fPush to toggle");
while(true)
{
if(!input(pin_C0))
{
printf(lcd_putc,"\f Status =");
toggle = !toggle;
if( !toggle )
{ printf(lcd_putc," Low"); Led_OFF; }
else
{ printf(lcd_putc," High"); Led_ON; }
}
do
{ delay_ms(10);
} while(!input(pin_C0)); //Debounce
}
}
|
Humberto |
|
 |
Guest
|
|
Posted: Mon Nov 06, 2006 2:23 am |
|
|
Thanks Humberto it works fine i edit the last while statement
| Code: | | while(!input(pin_C0)); //Debounce |
to
| Code: | | while(input(pin_C0)); //Debounce |
i use bootloader so i downloaded your code first the weird thing that i was push the push button and reset it was toggling else wasn't toggle C0 alone both they works then i removed the (!) from input it works |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|