*///////////////////////////////////////////////////////////////////
//Author : Palak Patel
//Contact No : 9173211683
//Title : Led Pattern(5 Patterns using Switch)
//Platform : 8051
//Software : Keil 4.0
//Created: 15-05-2014
////////////////////////////////////////////////////////////////////*
Program:
//Author : Palak Patel
//Contact No : 9173211683
//Title : Led Pattern(5 Patterns using Switch)
//Platform : 8051
//Software : Keil 4.0
//Created: 15-05-2014
////////////////////////////////////////////////////////////////////*
Program:
#include<reg51.h>
#define led P1
sbit sw=P2^0;sbit sw1=P2^1;
sbit sw2=P2^2;
sbit sw3=P2^3;
sbit sw4=P2^4;
void delay();
void main()
{
unsigned char k,k1,k2,i,j,g;
P:while(1)
{
if(sw==0 && sw1==1 && sw2==1 && sw3==1 && sw4==1)
{
while(1)
{
led=0x00;
delay();
led=0xff;
delay();
if(sw1==0 || sw2==0 || sw3==0 || sw4==0)
goto P;
}
}
else if(sw1==0 && sw==1 && sw2==1 && sw3==1 && sw4==1 )
{
while(1)
{
led=0x55;
delay();
led=0xaa;
delay();
if(sw==0 || sw2==0 || sw3==0 || sw4==0)
goto P;
}
}
else if(sw2==0 && sw==1 && sw1==1 && sw3==1 && sw4==1)
{
while(1)
{
led=0x01;
delay();
for(g=8 ; g>=1 ; g--)
{
led=led<<1;
delay();
}
if(sw1==0 || sw1==0 || sw3==0 || sw4==0)
goto P;
}
}
else if(sw3==0 && sw==1 && sw1==1 && sw2==1 && sw4==1)
{
while(1)
{
led=0x80;
delay();
for(g=8 ; g>=1 ; g--)
{
P1=P1>>1;
delay();
}
if(sw==0 || sw1==0 || sw2==0 || sw4==0)
goto P;
}
}
else if(sw4==0 && sw==1 && sw1==1 && sw2==1 && sw3==1)
{
while(1)
{
k2=0;
for(j=4 ; j>=1 ; j--)
{
k=0x01;
k1=0x80;
for(i=1 ; i<=j ; i++)
{
led=k | k1 | k2;
delay();
k=k<<1;
k1=k1>>1;
}
k2=led;
}
if(sw==0 || sw1==0 || sw2==0 || sw3==0)
goto P;
}
}
else
{
led=0x00;
}
}
}
void delay()
{
unsigned int i;
for(i=0 ; i<20000 ; i++);
}
Simulation:
...................................................................................................................................................................
PIC 18 F4520 Microcontroller
1).PIC18f4520 Features - Here
2).LED Interface With PIC18f4520 -Here
3).PWM using PIC18F4520 - Here
4).ADC 20 V Using PIC18F4520 - Here
7).USART Transmission With PIC18F4520 - Here
8).USART Receiver With PIC18F4520 - Here
9).RTC Interface Using I2C With PIC18F4520 -Here
10).DC Motor Interface With PIC18f4520 - Here
11).7 SEGMENT Interface With PIC18f4520 - Here
12).LCD 4_Bit Interface With PIC18F4520 -Here
13).LCD 8_Bit Interface with PIC18F4520 -Here
8051 Microcontroller
No comments:
Post a Comment