Working of all logic gates with 8051 project
After power supply is turned on ,first we select the logic gate. At one time we choose only one gate by pressing switch of corresponding gate. When logic gate is selected , corresponding led start glowing. After that there is two input are provided ,if input led glow means logic 1 otherwise logic 0. At output, one led is provided , if led glow means output is logic 1 otherwise logic 0.
1. Program of all logic gates with 8051
/******************************************************
www.firmcodes.com
DEVELOPED BY:- FIRMWARE DEVELOPER
WHAT PROGRAM DO:- Program of Visitor Counter with 8051 using LCD
******************************************************/
#include<reg51.h>
sbit x=P1^0;
sbit y=P1^1;
sbit and=P2^0; // and gate
sbit or=P2^1; // or gate
sbit nand=P2^2; // nand gate
sbit nor=P2^3; // nor gate
sbit xor=P2^4; // xor gate
sbit xnor=P2^5; // xnor gate
sbit out=P3^0; // output
/******************************
main program
******************************/
void main ()
{
unsigned char a,b,c,d,i,j;
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
if(x==i&&y==j)
{
if(and==0)
{
out=x & y;
}
else if(or==0)
{
out=x | y;
}
else if(nand==0)
{
a=x & y;
out=! a;
}
else if(nor==0)
{
a=x | y;
out=! a;
}
else if(xor==0)
{
a=! x;
b=! y;
c=x & b;
d=y & a;
out=c | d;
}
else if(xnor==0)
{
a=x & y;
b=! x;
c=! y;
d=b & c;
out=a | d;
}
}
}
}
}
PROTEUS File for SIMULATION(Password Of RAR file is :-firmcodes.com)
Coming soon….



