CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Switch toggle High/Low
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Guest








PostPosted: Sat Nov 04, 2006 5:06 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Nov 04, 2006 9:39 am     Reply with quote

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








PostPosted: Mon Nov 06, 2006 2:23 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
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