EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Replies / Pic 16F877A

Pic 16F877A

|

Microcontroller › Arduino › Why does arduino shows “fingerprint sensor not found” even after connecting the fingerprint module properly? › Pic 16F877A

April 26, 2016 at 6:48 pm #13899
Muhammad Muaaz Khan
Participant

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
}
}
}
}

RSS Recent Posts

  • Why aren’t the power windows in my 2006 Volkswagen Polo 2006 working despite repairing the control unit circuit board? May 10, 2026
  • Voltage comparator circuit verification May 10, 2026
  • What is this??? May 9, 2026
  • infiniBand Layer 1 specifications testing question May 8, 2026
  • block RF May 8, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise