单片机基本程序
Company number【1089WT-1898YT-1W8CB-9UUT-92108】
1第一位隔一秒闪烁一次
#include
2复杂广告灯 #include
{ led1=0; }
for(i=1000;i>0;i--) for(j=110;j>0;j--); led1=1;
for(i=1000;i>0;i--) for(j=110;j>0;j--);
#defineucharunsignedchar
uchardiscode[]={0xFE,0xFD,0xFB,0xF7,0xEF,0xDF,0xBF,0x7F,//正向流水灯
0xBF,0xDF,0xEF,0xF7,0xFB,0xFD,0xFE,0xFF,//反向流水灯
0xAA,0x55,0xAA,0x55,0xAA,0x55,0xFF,//隔灯闪烁3次
0xF0,0x0F,0xF0,0x0F,0xFF,//高四盏。
低四盏闪烁2次
0x33,0xCC,0x33,0xCC,0x33,0xCC,0xFF//
隔两盏闪烁3次
};
voiddelayms(uintms) { uinti; }
voidmain(void) { uchari;
while(ms--) {
for(i=0;i<120;i++); }
{ } }
P0=0xFF; while(1) {
for(i=0;i<35;i++)
P0=discode[i];
delayms(250);
}
3拉幕式与闭幕式广告灯 #include
uchardiscode1[4]={0x18,0x24,0x42,0x81}; uchardiscode2[4]={0x7E,0x3C,0x18,0x00}; voiddelayms(uintms) {
uinti; while(ms--)
{
for(i=0;i<120;i++);
}
}
voidmain(void) {
uchari,j; P0=0xFF; while(1) {
for(i=0;i<4;i++)
{
j=discode1[i]; }
P0=~j; delayms(500);
j=0xFF; P0=~j; delayms(500); for(i=0;i<4;i++) {
j=discode2[i];
P0=~j; delayms(500);