View previous topic :: View next topic |
Author |
Message |
letrungkien7
Joined: 12 Nov 2011 Posts: 2
|
16f690 Switch button |
Posted: Sat Nov 12, 2011 3:47 am |
|
|
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
|
? |
Posted: Sat Nov 12, 2011 5:14 am |
|
|
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.
? |
|
|
|
|
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
|