// Project name : Keypad Controlled Leds
// Designed By  : ROBOMART
//                http://www.robomart.com

/* Program for "Controlling Leds Using Keypad" 
___________________________________________________

Connection settings of Kit

8bit Keypad---@------------->P0

LED---@------------->P2

RESET-------------------------->PIN9
Crystal Ossilator-------------->PIN18 and PIN19
VCC=Regulated 5V
Gnd=Ground(0V)
*/

  #include<reg52.h>
  void delay(unsigned int);
  sbit switch1 = P0^0;		  // key 0 connected to P0^0
  sbit switch2 = P0^1;		  // key 1 connected to P0^1
  sbit switch3 = P0^2;		  // key 2 connected to P0^2
  sbit switch4 = P0^3;		  // key 3 connected to P0^3
  sbit switch5 = P0^4;		  // key 4 connected to P0^4
  sbit switch6 = P0^5;		  // key 5 connected to P0^5
  sbit switch7 = P0^6;		  // key 6 connected to P0^6
  sbit switch8 = P0^7;		  // key 7 connected to P0^7
  void main(void)
  {
  switch1=1;
  switch2=1;
  switch3=1;
  switch4=1;
  switch5=1;				   // make all switch as input device
  switch6=1;
  switch7=1;
  switch8=1;
  P2=0x00;					   // Port 2 as Output Device for LEDs
  while(1)
  {
  if(switch1==1)
  {
  P2=0x01;					   // 1st Led will glow
  delay(200);
  P2=0x00;	   			     	//	Led will be off
   }						   
  
  }
  }

void delay(unsigned int time)
{ 
unsigned int i,j;
for(i=0;i<time;i++)
	for(j=0;j<1275;j++);
}


