Write a program for 4*4 matrix using switches – Embedded System Using C


Program for 4*4 matrix using switches.

#include<8051.h>
void main()
{
P0=0xff;
P1=0x00;
while(1)
{
if(P0_0==0 && P0_4==0)
{
P1=0x01;
}
if(P0_0==0 && P0_5==0)
{
P1=0x02;
}
if(P0_0==0 && P0_6==0)
{
P1=0x03;
}
if(P0_0==0 && P0_7==0)
{
P1=0x04;
}
if(P0_1==0 && P0_4==0)
{
P1=0x05;
}
if(P0_1==0 && P0_5==0)
{
P1=0x06;
}
if(P0_1==0 && P0_6==0)
{
P1=0x07;
}
if(P0_1==0 && P0_7==0)
{
P1=0x08;
}
if(P0_2==0 && P0_4==0)
{
P1=0x09;
}
if(P0_2==0 && P0_5==0)
{
P1=0x0a;
}
if(P0_2==0 && P0_6==0)
{
P1=0x0b;
}
if(P0_2==0 && P0_7==0)
{
P1=0x0c;
}
if(P0_3==0 && P0_4==0)
{
P1=0x0d;
}
if(P0_3==0 && P0_5==0)
{
P1=0x0e;
}
if(P0_3==0 && P0_6==0)
{
P1=0x0f;
}
if(P0_3==0 && P0_7==0)
{
P1=0x10;
}
}
}

Add Comment