单片机广告灯的设计C语言程序<分数不多 但求大神告知 好人一生平安>

单片机广告灯的设计C语言程序<分数不多 但求大神告知 好人一生平安>,第1张

#include<reg51.h>

#define uchar unsigned char

uchar ledt[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f}

uchar ledi[]={0xfc,0xf9,0xf3,0xe7,0xcf,0x9f,0x3f,0x7e)

uchar nt=0,ni=0

void timer0() interrupt 1

{

TH0=(65536-50000)/256

TL0=(65536-50000)%256

switch(nt)

{

case 0:

case 1:

case 2:

case 3:

case 4:

case 5:

case 6:

case 7:

P1=ledt[nt]break

case 8:

case 9:

case 10:

case 11:

case 12:

case 13:

case 14:

p1=ledt[14-nt]break

case 15:

P1=0x00break

case 16:

P1=0xffbreak

default:

nt=0break

}

nt++

}

void ext0() interrupt 0

{

switch(ni)

{

case 0:

case 1:

case 2:

case 3:

case 4:

case 5:

case 6:

case 7:

P1=ledt[ni]break

case 8:

case 9:

case 10:

case 11:

case 12:

case 13:

case 14:

P1=ledt[14-ni]break

case 15:

P1=0xffbreak

case 16:

P1=0x00break

default:

ni=0break

}

}

void delay(uchar a)

{

uchar i,j

for(i=0i<ai++)

for(j=0j<120j++)

}

main()

{

TMOD=0x01

TH0=(65536-50000)/256

TL0=(65536-50000)%256

ET0=1

EX0=1

IT0=0

EA=1

TR0=1

while(1)

{

while(P3_2)

{

TR0=0

delay(50)

ni++

}

TR0=1

}

#include<reg51.h>

unsigned char time=0

void delay(unsigned long w)

{

while(w--)

}

void zuoxunhuan()

{

unsigned char C

for(C=0x80C!=0C>>=1) //左移

{

P1=C

delay(30000)

}

}

void youxunhuan()

{

unsigned char C

for(C=0x01C!=0C<<蚂判=1) //右移

{

P1=C

delay(30000)

}

}

void zengti() //递增

{

unsigned int C

for(C=0xFEC!=0C<<=1)

{

P1=~C

delay(30000)

}

}

void jiaoti() /瞎握/交替

{

P1=0x55

delay(30000)

P1=0xaa

delay(30000)

}

void init_init()

{

EX0=1

EA=1

}

void into_into() interrupt 0 //P3.2外接磨物庆一个按键底电瓶有效切换程序

{

if((time+=1)==5) time=0

delay(400000)

}

void main()

{

init_init()

while(1)

{

if(time==1) zuoxunhuan()

if(time==2) youxunhuan()

if(time==3) zengti()

if(time==4) jiaoti()

if(time==0)

{

zuoxunhuan()

youxunhuan()

zengti()

jiaoti()

}

}

}

#include<reg52.h>

#include<毁裤intrins.h>

#define uint unsigned int

#define uchar unsigned char

sbit key1=P3^4//¶ÀÁ¢¼üÅÌ

sbit key2=P3^5//¶ÀÁ派余败¢¼üÅÌ

uchar t,temp

void delay(uchar z)

{

uchar x,y

for(x=zx>0x--)

for(y=110y>0y--)

}

void init()

{

TMOD=0x01

TH0=(65536-50000)/256

TL0=(65536-50000)%256

EA=1

ET0=1

TR0=1

temp=0xfe

t=0

P3=0xff

}

void main()

{

init()

while(1)

{

if(t==20)

{

t=0

P1=temp

temp=_crol_(temp,1)

}

if(key1==0)

{

TR0=0

P1=0xff

while(!key1)

}

if(key2==0)

{

TR0=0

P1=0

while(!key2)

}

}

}

void timer0() interrupt 1

{

TH0=(65536-50000)/尘颤256

TL0=(65536-50000)%256

t++

}


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/12455270.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-25
下一篇 2023-05-25

发表评论

登录后才能评论

评论列表(0条)

保存