Microcontroller › Arduino › Why does arduino shows “fingerprint sensor not found” even after connecting the fingerprint module properly? › Pic 16F877A
Please Can any one help me on this code I am working with PIC 16F877A controller On mikroC compiler. My code work right but i it not stop while loop(1) when I pressed switch PORTD.F2 can any one tell me how I stop it and how I am going to Exit from whole loop(1) when I pressed PORTD.F2 == 0
void main()
{
TRISD.F0 = 1; //Configure 1st bit of PORTD as input
TRISD.F1 = 1; //Configure 1st bit of PORTD as input
TRISD.F2 = 1; //Configure 1st bit of PORTD as input
TRISD.F3 = 1; //Configure 1st bit of PORTD as input
TRISB.F0 = 0; //Makes PORTB0 or RB0 Output Pin
TRISB.F1 = 0; //Makes PORTB1 or RB0 Output Pin
TRISB.F2 = 0; //Makes PORTB0 or RB0 Output Pin
TRISB.F3 = 0; //Makes PORTB1 or RB0 Output Pin
TRISB.F4 = 0; //Makes PORTB0 or RB0 Output Pin
TRISB.F5 = 0; //Makes PORTB1 or RB0 Output Pin
TRISB.F6 = 0; //Makes PORTB0 or RB0 Output Pin
TRISB.F7 = 0; //Makes PORTB1 or RB0 Output Pin
while(1) //Infinite Loop
{
if(PORTD.F1 == 0) //If the switch is pressed
{
PORTB.F0 = 1; //LED ON
PORTB.F1 = 0; //LED OFF
PORTB.F2 = 0; //LED OFF
PORTB.F3 = 1; //LED OFF
PORTB.F4 = 1; //LED ON
PORTB.F5 = 0; //LED OFF
PORTB.F6 = 0; //LED OFF
PORTB.F7 = 1; //LED ON
Delay_ms(2000); //1 Second Delay
PORTB.F0 = 0; //LED OFF
PORTB.F3 = 0; //LED OFF
PORTB.F4 = 0; //LED OFF
PORTB.F5 = 0; //LED OFF
PORTB.F6 = 0; //LED OFF
PORTB.F7 = 0; //LED OFF
}
if(PORTD.F0 == 0) //If the switch is pressed
{
PORTB.F1 = 1; //LED ON
PORTB.F0 = 0; //LED OFF
PORTB.F2 = 1; //LED ON
PORTB.F3 = 0; //LED OFF
PORTB.F4 = 0; //LED OFF
PORTB.F5 = 1; //LED ON
PORTB.F6 = 1; //LED ON
PORTB.F7 = 0; //LED OFF
Delay_ms(2000); //1 Second Delay
PORTB.F1 = 0; //LED OFF
PORTB.F2 = 0; //LED OFF
PORTB.F3 = 0; //LED OFF
PORTB.F4 = 0; //LED OFF
PORTB.F5 = 0; //LED OFF
PORTB.F6 = 0; //LED OFF
PORTB.F7 = 0; //LED OFF
}
if(PORTD.F3 == 0) //If the switch is pressed
{
PORTB.F0 = 0; //LED OFF
PORTB.F1 = 0; //LED OFF
PORTB.F2 = 0; //LED OFF
PORTB.F3 = 0; //LED OFF
PORTB.F4 = 0; //LED OFF
PORTB.F5 = 0; //LED OFF
PORTB.F6 = 0; //LED OFF
PORTB.F7 = 0; //LED OFF
Delay_ms(5000); //1 Second Delay
}
if(PORTD.F2 == 0) //If the switch is pressed
{
while(1) //Infinite Loop
{
PORTB.F0 = 0; //LED OFF
PORTB.F1 = 1; //LED ON
PORTB.F2 = 0; //LED OFF
PORTB.F3 = 0; //LED OFF
PORTB.F4 = 0; //LED OFF
PORTB.F5 = 0; //LED OFF
PORTB.F6 = 0; //LED OFF
PORTB.F7 = 0; //LED ON
Delay_ms(500); //1 Second Delay
PORTB.F3 = 1; //LED ON
PORTB.F0 = 0; //LED OFF
PORTB.F1 = 1; //LED ON
PORTB.F2 = 0; //LED OFF
PORTB.F4 = 0; //LED OFF
PORTB.F5 = 0; //LED OFF
PORTB.F6 = 0; //LED OFF
PORTB.F7 = 0; //LED OFF
Delay_ms(1000); //1 Second Delay
PORTB.F0 = 1; //LED ON
PORTB.F1 = 0; //LED OFF
PORTB.F2 = 1; //LED ON
PORTB.F3 = 0; //LED OFF
PORTB.F4 = 0; //LED OFF
PORTB.F5 = 0; //LED OFF
PORTB.F6 = 0; //LED OFF
PORTB.F7 = 0; //LED OFF
Delay_ms(100); //1 Second Delay Both legs are off
PORTB.F0 = 0; //LED OFF
PORTB.F1 = 0; //LED OFF
PORTB.F2 = 0; //LED OFF
PORTB.F3 = 0; //LED OFF
PORTB.F4 = 0; //LED OFF
PORTB.F5 = 0; //LED OFF
PORTB.F6 = 0; //LED OFF
PORTB.F7 = 0; //LED OFf
Delay_ms(500); //1 Second Delay second leg Left leg
PORTB.F0 = 0; //LED OFF
PORTB.F1 = 0; //LED OFF
PORTB.F2 = 0; //LED OFF
PORTB.F3 = 0; //LED OFF
PORTB.F4 = 0; //LED OFF
PORTB.F5 = 1; //LED ON
PORTB.F6 = 0; //LED OFF
PORTB.F7 = 0; //LED OFF
Delay_ms(500); //1 Second Delay
PORTB.F0 = 0; //LED OFF
PORTB.F1 = 0; //LED OFF
PORTB.F2 = 0; //LED OFF
PORTB.F3 = 0; //LED OFF
PORTB.F4 = 0; //LED OFF
PORTB.F5 = 1; //LED ON
PORTB.F6 = 0; //LED OFF
PORTB.F7 = 1; //LED ON
Delay_ms(1000); //1 Second Delay
PORTB.F0 = 0; //LED OFF
PORTB.F1 = 0; //LED OFF
PORTB.F2 = 0; //LED OFF
PORTB.F3 = 0; //LED OFF
PORTB.F4 = 1; //LED ON
PORTB.F5 = 0; //LED OFF
PORTB.F6 = 1; //LED ON
PORTB.F7 = 0; //LED OFF
Delay_ms(100); //1 Second Delay Both legs are off
PORTB.F0 = 0; //LED OFF
PORTB.F1 = 0; //LED OFF
PORTB.F2 = 0; //LED OFF
PORTB.F3 = 0; //LED OFF
PORTB.F4 = 0; //LED OFF
PORTB.F5 = 0; //LED OFF
PORTB.F6 = 0; //LED OFF
PORTB.F7 = 0; //LED OFf
Delay_ms(1000); //1 Second Delay
}
}
}
}