4Button Latch with PIC 16F877A Microcontroller in PMLAB IDE

Download links

Binary file--

https://drive.google.com/file/d/1epSNl9kr73Ob__JnYGZGZBSZXIOtD9uE/view?usp=sharing

MPLAB.C file--

https://drive.google.com/file/d/1IWnJpzJBHXN1jPJR-MjLUkMWEC-_hVfG/view?usp=sharing 

Proteus Circuit--

 https://drive.google.com/file/d/1epSNl9kr73Ob__JnYGZGZBSZXIOtD9uE/view?usp=sharing


/*MPLAB Code for 4 button Latch with PIC16F877A
 * File:   4Buttonmain.c
 * Author: Anokhautomation
 *
 * Created on July 12, 2022, 12:02 AM
 */
#include <xc.h>
__CONFIG(FOSC_HS & WDTE_OFF & PWRTE_OFF & BOREN_OFF & LVP_OFF & CPD_OFF & WRT_OFF & CP_OFF);
#define _XTAL_FREQ 10000000
#define SW1 RD4//connect button 1 to Pin RD4
#define SW2 RD5//connect button 2 to Pin RD5
#define SW3 RD6//connect button 3 to Pin RD6
#define SW4 RD7//connect button 4 to Pin RD7
void main(void) {
  TRISB = 0X00;//Set PORTB pins to OUTPUT 
PORTB = 0X00; // at Initial, value of PORTB are 0

     while(1){

              if(SW1==1){ //if button1 is  Pressed

                         RB0 = ~RB0;   // Change the RB0 current state to opposit state


                         while(SW1==1);     // switch debounce

                         }

              if(SW2==1){//if button2 is  Pressed

                         RB1= ~RB1;    // Change the RB1current state to opposit state

                         while(SW2==1);        // Switch debounce

                         }

              if(SW3==1){//if button3 is  Pressed

                         RB2 = ~RB2;     // Change the RB2current state to opposit state


                         while(SW3==1);           // Switch debounce

                         }

              if(SW4==1){//if button4 is  Pressed

                         RB3= ~RB3;      // Change the RB3current state to opposit state


                         while(SW4==1);            // Switch debounce
}
 }
return;
}
  
    
    
    
    
    


Comments

Popular posts from this blog

Proteus simulation 4x4 Matrix Keypad with Arduino and LCD screen

Digital Clock with Arduino and RTC Module and P10 LEDmatrix

Interfacing KY038 sound sensor with Raspberry pi Pico