Andrew744
Newbie level 3
- Joined
- Dec 20, 2012
- Messages
- 3
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,300
Dear Community,
Please help me in my time of need.
I'm trying to program a PIC12F629 micro controller to have 2 buttons, each button turns an led on when it's depressed. For some weird reason if I press both buttons down at the same time and let one go both led will stay on. When only one led should stay on.
Here's I schematic of my bread board. It's terrible so bear with me here.
Please help me in my time of need.
I'm trying to program a PIC12F629 micro controller to have 2 buttons, each button turns an led on when it's depressed. For some weird reason if I press both buttons down at the same time and let one go both led will stay on. When only one led should stay on.
Here's I schematic of my bread board. It's terrible so bear with me here.
Code:
#include <htc.h>
#define _XTAL_FREQ 4000000
__CONFIG(MCLRE_OFF & CP_OFF & BOREN_OFF & WDTE_OFF & FOSC_INTRCIO & PWRTE_ON);
void main(){
ANSEL=0; // Required for all digital I/O on PIC12F675
GPIO = 0b000000; // Preset output latches to all low
TRISIO = 0b001000; // All I/Os (except GPIO3 (/MCLR) as outputs
//CMCON = 0; //New For Input
while(1){
if(GPIObits.GP2 == 1)
{
GPIObits.GP1 = 1;
}
else
{
GPIObits.GP1 = 0;
}
if(GPIObits.GP5 == 1)
{
GPIObits.GP4 = 1;
}
else
{
GPIObits.GP4 = 0;
}
}
}