| |

Fig.5
|
|
| |
|
Example program to blink led on port2 (Compile with KEIL C51) |
|
|
|
|
|
#include <reg52.h>
//=========================
// delay function
//=========================
void delay(int del_val)
{
int i,k;
for(i=0;i<=del_val;i++)
for(k=0;k<=50;k++);
}
//=== main program =========
void main()
{
int count,patt;
while(1)
{
patt=0x1; // 00000001
for(count=0;count<=8;count++)
{
P2=~patt;
patt=patt<<1;
delay(1000);
}
patt=0x80; // 10000000
for(count=0;count<=8;count++)
{
P2=~patt;
patt=patt>>1;
delay(1000);
}
}
} // end of main program
|
|
|
Copyright(c) 2005-2010 sixca.com, All rights reserved.
Best view @ 800X600, IE 6.0 up Terms Privacy
|
|
|