霓虹灯的电路图:
霓虹灯的51单片机程序:
#include
#define uchar unsigned char
#define uint unsigned int
sbit RED_LED = P1^0; //端口定义.
sbit GREEN_LED = P1^1;
sbit YELLOW_LED = P1^2;
uint flicker,i,n;
void int0()
{
TMOD=0x01;
TH0=0x3C;
TL0=0xAF;
TR0=1; //启动定时器。
ET0=1; //开定时器中断.
EA=1; //开总中断
}
void main() //主函数。
{
n=0;
i=0;
GREEN_LED=1;
YELLOW_LED=1;
flicker=0;
int0();
while(1)
{
if(0<=n&&n<20)
{
YELLOW_LED=1;