How to Interface push button with 8051

By | June 28, 2015

 

 8051 push button interfacing – Block diagram

8051 push button interfacing – Block diagram

8051 push button interfacing – code

/* 
 * Project : Push Button interfacing with 8051 Microcontroller.
 * Description : This project is all about interfacing a push button to 
 * 8051. Push button is connected to P2^0 in active low mode. 
 * LED is connected to P1^0 in active low mode. 
 * when we press the swith LED will blink.
 *        
 * Software : Keil uVison4
 * MCU : AT89S51/S52/C51/C52
 * Oscillator : 11.0592 Mhz
 * Date	: 05-05-2015
 */   
#include <reg51.h>

sbit PushButton = P2^0;
sbit Led = P1^0;

void main()
{
PushButton = 1;
 while(1)  // For ever 
 {
  if(PushButton == 0)  // if press Push button
  { 
    Led = 0;			   // ON LED ( active low )
	    while(PushButton == 0);// Wait here for release of push button
  }
  Led = 1;
 }
}
/*    The End     */

 

8051 push button interfacing – circuit

8051 push button interfacing – circuit

8051 push button interfacing – output image

8051 push button interfacing – output image

8051 push button interfacing – video

One thought on “How to Interface push button with 8051

  1. Hosting

    Can anyone please help? can i make a program that does something when i press a push button for some time?

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *