*///////////////////////////////////////////////////////////////////
//Author : Palak Patel
//Contact No : 9173211683
//Title : Led Pattern
//Platform : 8051
//Software : Keil 4.0
//Created: 15-05-2014
////////////////////////////////////////////////////////////////////*
In this program as you press the switch it will increament the led..
Program:
#include<reg51.h>
#define led P1
sbit sw=P2^0;
void delay();
void main()
{
unsigned char k;
led=0x00;
k=0x00;
while(1)
{
if(sw==0)
{
k=(2*k)+1;
led=k;
delay();
if(k==255)
k=0;
}
}
}
void delay()
{
unsigned int i;
for(i=0;i<40000;i++);
}
Simulation:
//Author : Palak Patel
//Contact No : 9173211683
//Title : Led Pattern
//Platform : 8051
//Software : Keil 4.0
//Created: 15-05-2014
////////////////////////////////////////////////////////////////////*
In this program as you press the switch it will increament the led..
Program:
#include<reg51.h>
#define led P1
sbit sw=P2^0;
void delay();
void main()
{
unsigned char k;
led=0x00;
k=0x00;
while(1)
{
if(sw==0)
{
k=(2*k)+1;
led=k;
delay();
if(k==255)
k=0;
}
}
}
void delay()
{
unsigned int i;
for(i=0;i<40000;i++);
}
Simulation:
...................................................................................................................................................................
PIC 18 F4520 Microcontroller
No comments:
Post a Comment