11.15在淘宝下单买了大部分东西,在一个店买的.。些东西像MCU、电阻自己有,就没买了,有些像电源,DC座根本没打算用,有些像紧锁座,排针不在EEPW元件清单里,但个人认为应该有,还有像数码管好像买错了,当然,可能还有漏买的,到时去市场买吧。东西怎么样还不知道,待到货上传照片。



板子收到两天了,收到当天就焊了个最小系统,没时间加怕焊出来用不了,多的没焊。回家发现居然用不了,烧了程序的单片机装上去也不工作,没办法等今天上班到公司查,发现居然晶振坏了。。板子的焊盘太小,一拆就掉铜皮,晶振只好焊在了正面。板子现在只焊了这个样子,需要什么再焊吧。
手里只有AT89S52,好像不能用串口下载,没办法用烧录器烧好装上去。
先上个最简单的流水灯程序吧,最简单的程序,谁都会。程序如下:
#include <AT89X51.H>
unsigned char code table[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,
0xfc,0xf9,0xf3,0xe7,0xcf,0x9f,0x3f,0x81,
0xf8,0xf1,0xe3,0xc7,0x8f,0x1f,0x3e,0x7c,
0xf0,0xe1,0xc3,0x87,0x0f,0x1e,0x3c,0x78,
0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00,
0x01,0x03,0x07,0x0f,0x1f,0x3f,0x7f,0xff,
0x00,0xff,0x00,0xff,
0xee};
unsigned char i=0;
void delay(void)
{
unsigned char m,n;
for(m=1500;m>0;m--)
for(n=500;n>0;n--);
}
void main(void)
{
while(1)
{
if(table[i]!=0xee)
{
P1=table[i];
i++;
delay();
}
else
{
i=0;
}
}
}
不知道为什么不忙却总有些事,好久没更新了,先更新的1602的显示。
/********LCD1602显示程序********/
/******** 2011-12-01 ********/
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit rs=P2^4;
sbit rw=P2^5;
sbit lcden=P2^6;
uchar table1[]="HELLO EEPW";
uchar table2[]="1602 DISPLAY";
void delay(uint x)
{
uint a,b;
for(a=x;a>0;a--)
for(b=10;b>0;b--);
}
void write_command(uchar command) //写指令子程序;
{
P0=command;
rs=0;
delay(10);
lcden=1;
delay(10);
lcden=0;
}
void write_date(uchar date)
{ //写数据子程序;
P0=date;
rs=1;
delay(10);
lcden=1;
delay(10);
lcden=0;
}
void main()
{
uchar a;
rw=0;
write_command(0x38); //8位数据线,两行,5X7点阵
delay(20);
write_command(0x0c); //开显示,光标不显示,不闪烁
delay(20);
write_command(0x06); //光标右移1位,显示不移
delay(20);
write_command(0x01); //清显示;
delay(20);
write_command(0x80+19);//第1行字符;
delay(20);
for(a=0;a<10;a++)
{
write_date(table1[a]);
delay(20);
}
write_command(0xc0+18); //第2行字符;
delay(50);
for(a=0;a<12;a++)
{
write_date(table2[a]);
delay(40);
}
for(a=0;a<16;a++) //字符往左移动;
{
write_command(0x18); //光标与显示一起向左移动,AC值不变;
delay(2000);
}
while(1);
}
好久没有更新了,都有点不好意思露面了。最近把该焊的都焊完,在1602程序里加入了矩阵键盘的使用
/*************LCD1602显示程序*****************/
/************** 2011-12-01 ****************/
/********2011-12-21 增加矩阵键盘的使用*******/
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit rs = P2^4;
sbit rw = P2^5;
sbit lcden = P2^6;
sbit key_lin1 = P3^4;
sbit key_lin2 = P3^5;
sbit key_lin3 = P3^6;
sbit key_lin4 = P3^7;
uchar temp;
uchar key;
uchar i, j;
uchar table1[] = "HELLO EEPW";
uchar table2[] = "KEY S";
uchar table[] = {" 1 2 3 4 5 6 7 8 910111213141516"};
void delay(uint x)
{
uint a,b;
for(a = x; a > 0; a--)
for(b = 10; b > 0; b--)
{
;
}
}
void write_command(uchar command) //写指令子程序;
{
P0 = command;
rs = 0;
delay(10);
lcden = 1;
delay(10);
lcden = 0;
}
void write_date(uchar date)
{ //写数据子程序;
P0 = date;
rs = 1;
delay(10);
lcden = 1;
delay(10);
lcden = 0;
}
void main()
{
/******LCD1602初始化******/
uchar a;
rw = 0;
write_command(0x38); //8位数据线,两行,5X7点阵
delay(20);
write_command(0x0c); //开显示,光标不显示,不闪烁
delay(20);
write_command(0x06); //光标右移1位,显示不移
delay(20);
write_command(0x01); //清显示;
delay(20);
write_command(0x80+3); //第1行字符;
delay(20);
for(a = 0; a < 10; a++)
{
write_date(table1[a]);
delay(20);
}
write_command(0xc0+4); //第2行字符;
delay(50);
for(a = 0; a < 5; a++)
{
write_date(table2[a]);
delay(40);
}
while(1)
{
/*P3.4输出低电平,通过检测P3.0-P3.3的电平来判断第4竖排按键是否按下*/
P3 = 0xff;
key_lin1 = 0;
temp = P3;
temp = temp & 0x0f;
if (temp != 0x0f)
{
for(i=50;i>0;i--)
for(j=200;j>0;j--)
{
;
}
temp = P3;
temp = temp & 0x0f;
if (temp != 0x0f)
{
temp = P3;
temp = temp & 0x0f;
switch(temp)
{
case 0x0e:
key = 13;
break;
case 0x0d:
key = 14;
break;
case 0x0b:
key = 15;
break;
case 0x07:
key = 16;
break;
}
temp = P3;
write_command(0xc0 + 9);
delay(50);
a = key * 2 - 2;
write_date(table[a]);
delay(40);
write_date(table[a+1]);
delay(40);
temp = temp & 0x0f;
while(temp != 0x0f)
{
temp = P3;
temp = temp & 0x0f;
}
}
}
/*P3.5输出低电平,通过检测P3.0-P3.3的电平来判断第3竖排按键是否按下*/
P3 = 0xff;
key_lin2 = 0;
temp = P3;
temp = temp & 0x0f;
if (temp != 0x0f)
{
for(i = 50; i > 0; i--)
for(j = 200; j > 0; j--)
{
;
}
temp = P3;
temp = temp & 0x0f;
if (temp != 0x0f)
{
temp = P3;
temp = temp & 0x0f;
switch(temp)
{
case 0x0e:
key = 9;
break;
case 0x0d:
key = 10;
break;
case 0x0b:
key = 11;
break;
case 0x07:
key = 12;
break;
}
temp = P3;
write_command(0xc0 + 9);
delay(50);
a = key * 2 - 2;
write_date(table[a]);
delay(40);
write_date(table[a + 1]);
delay(40);
temp=temp & 0x0f;
while(temp != 0x0f)
{
temp = P3;
temp = temp & 0x0f;
}
}
}
/*P3.6输出低电平,通过检测P3.0-P3.3的电平来判断第2竖排按键是否按下*/
P3 = 0xff;
key_lin3 = 0;
temp = P3;
temp = temp & 0x0f;
if (temp != 0x0f)
{
for(i = 50; i > 0; i--)
for(j = 200; j > 0; j--)
{
;
}
temp = P3;
temp = temp & 0x0f;
if (temp != 0x0f)
{
temp = P3;
temp = temp & 0x0f;
switch(temp)
{
case 0x0e:
key = 5;
break;
case 0x0d:
key = 6;
break;
case 0x0b:
key = 7;
break;
case 0x07:
key = 8;
break;
}
temp = P3;
write_command(0xc0 + 9);
delay(50);
a = key * 2 - 2;
write_date(table[a]);
delay(40);
write_date(table[a + 1]);
delay(40);
temp = temp & 0x0f;
while(temp != 0x0f)
{
temp = P3;
temp = temp & 0x0f;
}
}
}
/*P3.7输出低电平,通过检测P3.0-P3.3的电平来判断第1竖排按键是否按下*/
P3 = 0xff;
key_lin4 = 0;
temp = P3;
temp = temp & 0x0f;
if (temp != 0x0f)
{
for(i = 50; i > 0; i--)
for(j = 200; j > 0; j--)
{
;
}
temp = P3;
temp = temp & 0x0f;
if (temp != 0x0f)
{
temp = P3;
temp = temp & 0x0f;
switch(temp)
{
case 0x0e:
key = 1;
break;
case 0x0d:
key = 2;
break;
case 0x0b:
key = 3;
break;
case 0x07:
key = 4;
break;
}
temp = P3;
write_command(0xc0 + 9);
delay(50);
a = key * 2 - 2;
write_date(table[a]);
delay(40);
write_date(table[a + 1]);
delay(40);
temp=temp & 0x0f;
while(temp != 0x0f)
{
temp = P3;
temp = temp & 0x0f;
}
}
}
}
}
有奖活动 | |
---|---|
发原创文章 【每月瓜分千元赏金 凭实力攒钱买好礼~】 | |
【EEPW在线】E起听工程师的声音! | |
“我踩过的那些坑”主题活动——第001期 | |
高校联络员开始招募啦!有惊喜!! | |
【工程师专属福利】每天30秒,积分轻松拿!EEPW宠粉打卡计划启动! | |
送您一块开发板,2025年“我要开发板活动”又开始了! | |
打赏了!打赏了!打赏了! |
打赏帖 | |
---|---|
【我踩过的那些坑】工作那些年踩过的记忆深刻的坑被打赏10分 | |
【我踩过的那些坑】DRC使用位置错误导致的问题被打赏100分 | |
我踩过的那些坑之混合OTL功放与落地音箱被打赏50分 | |
汽车电子中巡航控制系统的使用被打赏10分 | |
【我踩过的那些坑】工作那些年踩过的记忆深刻的坑被打赏100分 | |
分享汽车电子中巡航控制系统知识被打赏10分 | |
分享安全气囊系统的检修注意事项被打赏10分 | |
分享电子控制安全气囊计算机知识点被打赏10分 | |
【分享开发笔记,赚取电动螺丝刀】【OZONE】使用方法总结被打赏20分 | |
【分享开发笔记,赚取电动螺丝刀】【S32K314】芯片启动流程分析被打赏40分 |