找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 1893|回復: 0
收起左側(cè)

pic交通燈程序

[復制鏈接]
ID:167274 發(fā)表于 2017-3-1 21:19 | 顯示全部樓層 |閱讀模式
#include <pic.h>
#include<stdio.h>
#define uint unsigned int
#define uchar unsiged char
uchar H_time=0,L_time=0;
const uchar tab[]={OxOa,Ox22,Ox11,Ox14};
extern uchar code[]={0x00,0x00,0x00,0x00};
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=5;y>0;y--);
}
void light(uchar n)
{
uchar i,top,temp;
for(;n>0;n--)
{
PORTC=H_time*16+L_time;
H_time++;L_time++;
temp=0x00;
for(i=0;i<0xff;i++)
{
temp++;
PORTD=temp;
delay(2);
}
}
}
viod RGB_light();

PORTB=tab[0];
light(7);H_time=0x00;
PORTB=tab[1];
light(2);H_time=0x00;L_time=0x00;
PORTB=tab[2];
light(7);L_time=0x00;
PORTB=tab[3];
light(2);H_time=0x00;L_time=0x00;
PORTB=0X00;
}
void main()
{
TRISD=0;
TRISB=0;
TORSI=0;
while(1);
}
}
}

回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網(wǎng)

快速回復 返回頂部 返回列表