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

16f690 Switch button

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



Joined: 12 Nov 2011
Posts: 2

View user's profile Send private message

16f690 Switch button
PostPosted: Sat Nov 12, 2011 3:47 am     Reply with quote

Please explain to me what is wrong with this code, which I got from a tutorial by Gooligum Electronics.


Code:

// PIN_A3->switch
// PIN_C0->LED

#include<16f690.h>

#fuses NOMCLR,NOPROTECT,NOWDT,INTRC
void main(){
   while(TRUE){
      output_c(input(PIN_A3) ? 0 : 0b000001);
   }
}


Result: The LED is turned on right away, do not wait for button to be pressed.

I understand that if that is the case, input(PIN_A3) is 1 by default and cannot be changed by pressing the button, right? So how do I use the switch button?

It works fine with the debounce hex file provided in pickit2 started.

Thanks in advanced.
letrungkien7



Joined: 12 Nov 2011
Posts: 2

View user's profile Send private message

?
PostPosted: Sat Nov 12, 2011 5:14 am     Reply with quote

It seems that THERE is nothing wrong with the code, but the programmer.

When I used Pickit2 in mplab, it does not work. Then I used Pickit2 programmer, it worked.
?
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