找回密码
 注册会员
img_loading
智能检测中
更新自动建库工具PCB Footprint Expert 2024.04 Pro / Library Expert 破解版

求助:简单LCD程序!

[复制链接]
admin 发表于 2012-9-3 01:57:01 | 显示全部楼层 |阅读模式

本文包含原理图、PCB、源代码、封装库、中英文PDF等资源

您需要 登录 才可以下载或查看,没有账号?注册会员

×
设计要求:P3.7口接一个开关,开关接地;P1.0~p1.3分别接一个led灯。程序开始后,P1.0接的led灯闪烁,当按以下开关后,P1.0口的灯熄灭,P1.1口的灯闪烁,再按开关,p1.1的灯灭,p1.2的灯亮,如此类推,到P1.3口的灯亮后,再按开关,p1.3的灯灭,p1.0的灯亮。
电路图如下:
5_27240_e85384a3107e9d5.jpg


本人编的程序如下。用proteus仿真,刚运行时P1.0口的灯按0.1秒周期闪烁,但按下开关后,P1.0口的灯灭,其他灯都没有反应。。不知道出了什么问题。。。希望大家能解答以下。。
PS:很明显,我是新手。。呵呵

#include<reg51.h>
#define uint unsigned int
uint k,i,count;
sbit P3_7=P3^7;
sbit P1_0=P1^0;
sbit P1_1=P1^1;
sbit P1_2=P1^2;
sbit P1_3=P1^3;

void key()
{
if(P3_7==0)
{for(k=0;k<10000;k++);
if(P3_7==0)
count++;
}
}
void timer0() interrupt 1 using 1
{ key();
if(count==0)
P1_0=!P1_0;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
if(count==1)
{P1_0=1;
P1_1=!P1_1;
}
if(count==2)
{P1_1=1;
P1_2=!P1_2;
}
if(count==3)
{P1_2=1;
P1_3=!P1_3;
}
if(count==4)
count=0;

}
void main()
{TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
EA=1;
ET0=1;
TR0=1;
do{}while(1);
}
您需要登录后才可以回帖 登录 | 注册会员

*滑块验证:
加载失败,请点击重试! (img)
本版积分规则

QQ|手机版|MCU资讯论坛 ( 京ICP备18035221号-2 )|网站地图

GMT+8, 2025-7-27 00:37 , Processed in 0.064796 second(s), 12 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表