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 support@ccsinfo.com

code to button switch on LCD

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Nebbiolo



Joined: 09 Jun 2019
Posts: 1

View user's profile Send private message

code to button switch on LCD
PostPosted: Sun Jun 09, 2019 6:18 pm     Reply with quote

Hi! Can anyone help with a solution to my code? I'm new about C language but, I'm learning a little every day. I wrote this code to make a button when pressed, turn on a LED and send to LCD the status of each LED. But I can't make this work properly!

That is what I would like to do:
When press button at RB3, turn on the LED A0 and show at LCD: Door 01,
and when I press again the RB3, turn the other LED A1 and show at LCD: Door 02.

Someone can tell me how to write correctly this code?
Code:

while(TRUE)
   {   
       if(input(PIN_B3) == 0){   
       printf(lcd_putc,"\fDOOR 01");
                             }

       if(input(PIN_B3) == 0){   
       printf(lcd_putc,"\fDOOR 02");
                             }
       
                                 
       if(input(PIN_B3) == 0){     
       output_toggle(PIN_A0);     
       output_toggle(PIN_A1);     
       delay_ms(500);             
                             }

Thank you so much for any help!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Jun 09, 2019 9:07 pm     Reply with quote

Two methods to read buttons are given here:
http://www.ccsinfo.com/forum/viewtopic.php?t=58066&start=7
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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