这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » DIY与开源设计 » 电子DIY » A670521546的MCU DIY进程贴 (蜂鸣器唱歌)

共20条 2/2 1 2 跳转至
助工
2011-11-30 12:16:26     打赏
11楼

是的,自己设计制作肯定最好了

但是考虑到一些初学者,不可能一下子就自己设计制作,需要一个过程的

不管怎么样,还是感谢EEPW的这次活动


助工
2011-11-30 22:04:54     打赏
12楼
今天板子大概焊接完毕,下午去买了些东东回来,然后将错误的给纠正重新焊接下,

焊接完毕,通电,发现只有LED1和LED2亮,开始还以为是我焊接有误,后发现本来就是这样,板子 本身存在bug。

再就是淘宝淘的IC座很水,STC12C5A16AD芯片在上面无法固定,接触不良,只有重新去买个替换掉了,大家要注意元器件的质量哦

发现LED有一个有问题,不知道是买的时候就有问题,还是我焊接时高温烧坏了,要更新掉

今天大概就这个样子了,继续奋斗!!!

助工
2011-12-01 14:48:07     打赏
13楼

差不多焊完了,但是问题一大堆,估计板子是废了,IC底座质量不过关,芯片安置不稳,接触不好,LED5不亮,奇怪了,LED2——LED9都亮除了LED5,检查,发现LED5是好的,有没有类似状况的?上几张图吧








打算用面包板来代替IC底座,继续下去···

悲催啊

菜鸟
2011-12-01 16:01:42     打赏
14楼

第一个问题不是问题,电容的封装是有这么一种画法,像很多电路板就是在负极涂白的。


助工
2011-12-01 22:13:50     打赏
15楼

发个流水灯灯程序:

#include<reg52.h>

unsigned char code led[]={0xfe,0xfd,0xfb,0xf7,
                          0xef,0xdf,0xbf,0x7f};

void delay1s()   //延时1s
{
unsigned char i,j,k;
for(i=100;i>0;i--)
for(j=20;j>0;j--)
for(k=248;k>0;k--);
}

 void main()
{
unsigned char i;
P1=0;
delay1s();
P1=0;
while(1){
for(i=0;i<8;i++)  //依次亮
  {
   P1=led[i] ;
   delay1s();
   }
   for(i=0;i<4;i++)   //偶数号灯亮
   {
   P1=led[2*i];
   delay1s();
   }
   for(i=0;i<4;i++)  //奇数号灯亮
   {
   P1=led[2*i+1];
   delay1s();
   }
   }
}






助工
2011-12-12 14:51:08     打赏
16楼

马上要考试,一直都在准备复习考试,所以有段时间没弄了,致歉!!!今天抽空夫学习了下,做了LCD 1602的实验:







源码:
#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[]="EEPW MCU-DIY";
uchar table2[]="WWW.EEPW.COM.CN";

void delay(uint x)
{
uint a,b;
for(a=x;a>0;a--)
for(b=10;b>0;b--);
}

void delay1(uint x)
{
uint a,b;
for(a=x;a>0;a--)
for(b=100;b>0;b--);
}

void write_com(uchar com)
{
P0=com;
rs=0;
rw=0;
lcden=0;
delay(10);
lcden=1;
delay(10);
lcden=0;
}

void write_date(uchar date)
{
P0=date;
rs=1;
rw=0;
lcden=0;
delay(10);
lcden=1;
delay(10);
lcden=0;
}

void init()
{
lcden=0;
write_com(0x38);
delay(20);
write_com(0x0c);
delay(20);
write_com(0x06);
delay(20);
write_com(0x01);
delay(20);
}

void main()
{
uchar a=0;
init();
 
write_com(0x80+17);
delay(20);
//for(a=0;a<12;a++)
while(table1[a]!='\0')
{
write_date(table1[a]);
a++;
//delay(10000);

write_com(0xc0+17);
delay(10000);
for(a=0;a<15;a++)
{
write_date(table2[a]);
delay(10000);
}
   
for(a=0;a<16;a++)
{
write_com(0x18);
delay1(10000);
}  
while(1); 
}


院士
2011-12-12 16:13:19     打赏
17楼
还好,不错

助工
2011-12-13 12:58:16     打赏
18楼
现在都要考试了。好长时间都没弄,现在还有考试,时间不多呐,尽量挤时间来继续,不能脱离了参加活动的本意

助工
2011-12-21 16:24:46     打赏
19楼

蜂鸣器唱歌的,曲子编码来自网络
直接放代码了:
#include<reg51.h>
unsigned char Count;
sbit Speak=P2^1;
unsigned char code Song[]={
                            
0x26,0x20,0x20,0x20,0x20,0x20,0x26,0x10,0x20,0x10,0x20,0x80,0x26,0x20,0x30 ,0x20,0x30,0x20,
0x39,0x10,0x30,0x10,0x30,0x80,0x26,0x20,0x20,0x20,0x20,0x20,0x1c,0x20,0x20,0x80,0x2b,0x20,
0x26,0x20,0x20,0x20,0x2b,0x10,0x26,0x10,0x2b,0x80,0x26,0x20,0x30,0x20,0x30,0x20,0x39,0x10,
0x26,0x10,0x26,0x60,0x40,0x10,0x39,0x10,0x26,0x20,0x30,0x20,0x30,0x20,0x39,0x10,0x26,0x10,
0x26,0x80,0x26,0x20,0x2b,0x10,0x2b,0x10,0x2b,0x20,0x30,0x10,0x39,0x10,0x26,0x10,0x2b,0x10,
0x2b,0x20,0x2b,0x40,0x40,0x20,0x20,0x10,0x20,0x10,0x2b,0x10,0x26,0x30,0x30,0x80,0x18,0x20,
0x18,0x20,0x26,0x20,0x20,0x20,0x20,0x40,0x26,0x20,0x2b,0x20,0x30,0x20,0x30,0x20,0x1c,0x20,
0x20,0x20,0x20,0x80,0x1c,0x20,0x1c,0x20,0x1c,0x20,0x30,0x20,0x30,0x60,0x39,0x10,0x30,0x10,
0x20,0x20,0x2b,0x10,0x26,0x10,0x2b,0x10,0x26,0x10,0x26,0x10,0x2b,0x10,0x2b,0x80,0x18,0x20,
0x18,0x20,0x26,0x20,0x20,0x20,0x20,0x60,0x26,0x10,0x2b,0x20,0x30,0x20,0x30,0x20,0x1c,0x20,
0x20,0x20,0x20,0x80,0x26,0x20,0x30,0x10,0x30,0x10,0x30,0x20,0x39,0x20,0x26,0x10,0x2b,0x10,
0x2b,0x20,0x2b,0x40,0x40,0x10,0x40,0x10,0x20,0x10, 0x20,0x10,0x2b,0x10,0x26,0x30,0x30,0x80,0x00,

//路边的野华不要采 , 以下为这首歌的编码

0x30,0x1C,0x10,0x20,0x40,0x1C,0x10,0x18,0x10,0x20,0x10,0x1C,0x10,0x18,0x40,0x1C,0x20,0x20,
0x20,0x1C,0x20,0x18,0x20,0x20,0x80,0xFF,0x20,0x30,0x1C,0x10,0x18,0x20,0x15,0x20,0x1C,0x20,
0x20,0x20,0x26,0x40,0x20,0x20,0x2B,0x20,0x26,0x20,0x20,0x20,0x30,0x80,0xFF,0x20,0x20,0x1C,
0x10,0x18,0x10,0x20,0x20,0x26,0x20,0x2B,0x20,0x30,0x20,0x2B,0x40,0x20,0x20,0x1C,0x10,0x18,
0x10,0x20,0x20,0x26,0x20,0x2B,0x20,0x30,0x20,0x2B,0x40,0x20,0x30,0x1C,0x10,0x18,0x20,0x15,
0x20,0x1C,0x20,0x20,0x20,0x26,0x40,0x20,0x20,0x2B,0x20,0x26,0x20,0x20,0x20,0x30,0x80,0x20,
0x30,0x1C,0x10,0x20,0x10,0x1C,0x10,0x20,0x20,0x26,0x20,0x2B,0x20,0x30,0x20,0x2B,0x40,0x20,
0x15,0x1F,0x05,0x20,0x10,0x1C,0x10,0x20,0x20,0x26,0x20,0x2B,0x20,0x30,0x20,0x2B,0x40,0x20,
0x30,0x1C,0x10,0x18,0x20,0x15,0x20,0x1C,0x20,0x20,0x20,0x26,0x40,0x20,0x20,0x2B,0x20,0x26,
0x20,0x20,0x20,0x30,0x30,0x20,0x30,0x1C,0x10,0x18,0x40,0x1C,0x20,0x20,0x20,0x26,0x40,0x13,
0x60,0x18,0x20,0x15,0x40,0x13,0x40,0x18,0x80,0x00
 };

void Time0_Init()
 {
 TMOD=0x01;
 IE  =0x82;
 TH0 =0xD8;
 TL0 =0xEF;
 }

 void Time0_Int() interrupt 1
 {
 TH0=0xD8;
 TL0=0xEF;
 Count++;
 }     

 void Delay_xMs(unsigned int x)
 {
 unsigned int i,j;
 for(i=0;i<x;i++)
 for(j=0;j<3;j++);
 }

 void Play_Song(unsigned char i)
 {
 unsigned char Temp1,Temp2;
 unsigned int Addr;
 Count=0;
 Addr=i*217;
 while(1)
 {
 Temp1=Song[Addr++];
 if(Temp1==0xFF)
 {
 TR0=0;
 Delay_xMs(100);
 }
 else if(Temp1==0x00)
 return;
 else
 {
 Temp2=Song[Addr++];
 TR0=1;
 while(1)
 {
 Speak=~Speak;
 Delay_xMs(Temp1);
 if(Temp2==Count)
 {
Count=0;
break;
 }
 }
 }
 }
 }

  void main()
  {
  Time0_Init();
  while(1)
  {
  Play_Song(1);
  }
  }

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


菜鸟
2012-01-28 14:34:04     打赏
20楼

共20条 2/2 1 2 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]