c语言编程跑马灯,走楼灯设计(C语言设计跑马灯程序)
for(i=0;i<125;i++);//延時1m
}void zy(void)//左移
{
unsigned char g,k;
g=0x01;
for(k=0;k<8;k++)
{
P1=~g;
yanshi(300);
g=g<<1;
}
}
void yy(void)//右移
{
unsigned char h,n;
h=0x80;
for(n=0;n<8;n++)
{
P1=~h;
yanshi(300);
h=h>>1;
}
}
/**********************/
INT_0()interrupt 0//外部中斷0
{
if(INT0==0)
a++;
if(a>2)a=1;
}/**********************/
main()
{
EA=1;//開總開關
IT0=1;//下降沿有效
EX0=1;//開外部中斷0
a=1;
while(1)
{
switch(a)
{
case 1:? zy();break;
case 2:? yy();break;
}
yanshi(10);
}
}
FPGA?跑馬燈設計
給你寫個大概吧:
第一步:按鍵控制state從0到3之間循環接環:
if key = 1
case s is
when s0: s=s1; out = 0x01;
when s1: s=s2: out = 0x80;
when s2: s=s3; out = 0x81;
when s3: s=s0; out = 0x18;
end case;
end key;
第二步:各個子狀態內部,燈的切換:
if clk is raising_edge then
case s is
when s = s0; out = out 向右循環位移1位
when s = s1; out = out 向左循環位移1位
when s= s2;
if out = ox81; out = 0x42;
if out = ox42; out = 0x24;
if out = ox24; out = 0x18;
if out = ox18; out = 0x81;
when s= s3;
if out = ox81; out = 0x18;
if out = ox42; out = 0x81;
if out = ox24; out = 0x42;
if out = ox18; out = 0x24;
end case
end if;
第三步,在上面兩個進程里添加rst控制
思路就是這樣的,看你的造化了
總結
以上是生活随笔為你收集整理的c语言编程跑马灯,走楼灯设计(C语言设计跑马灯程序)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: shiro---注解
- 下一篇: Shiro的authc过滤器的执行流程