fbpx

Interface Switch With 8051

The switch is a component that connect two points in a circuit when you press it

LED turns on when you press the button

Hardware Required

  • Push Button.
  • 220 ohms resistor
  • led
  • 8051 MicroController.

Circuit

Virtual Circuit

Code

#include <REGX51.h>  
void delay()
 {
  int i,j;
  for(i=0;i<1000;i++)
  {
   for(j=0;j<100;j++);
  }
 }
void main()
 {
  if(P1_0==0)
  {
   P0_0=0;
   delay();
  }
  else
  {
   P0_0=1;
   delay();
  }
 }

Leave a Reply

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