心型LED单片机制作

心型LED单片机制作,第1张

首先,单片机要有晶振和电容组成最小电路,其次,LED最好并联,不然电压下降太大,led亮不起来,并且led有正负极,长正短负,不能接反,把所有的正极接在一起接到单片机的某一脚,把所有负极接在一起并接地。单片机最好要有底座,直接可以将单片机插上去,不然单片机就是一次性的了,没办法取下来再用来装别的程序了。对于程序怎么装进去,首先得把程序放到keilc软件中编译,生成hex文件,然后用烧录软件烧到单片机中,通常是将单片机先插到单片机的开发板上烧录,然后取下来插到你的电路板上。单片机是好东西,学会了非常有用,建议你买一个开发板,再给你推荐郭天祥的单片机视频,非常有用,需要元器件可以网上购买。如果需要帮助可以看我上传的文库或者直接问我哦。

你用取模软件先点个心形,然后用字节左右移来实现就可以了

我有16*16点阵的各种动态效果程序

给你看下总共有12种动态效果,你改成8*8就可以了

/*************呈现各种显示效果的函数集****************/

void flash_bai(uchar *flash_word,uchar flash_heard,uchar number,uchar sdu,uchar state)//百叶窗效果

{register uchar i,j,k,l

for(i=0i<numberi++)

{

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

{

for(l=0l<8l++)

{

if(j<8)

{

dispram[l*4+1]=dispram[l*4+1]&0xff<<j|(flash_word[(flash_heard+i)*32+l*4]>>(7-j))

dispram[l*4+2]=dispram[l*4+2]&0xff>>j|(flash_word[(flash_heard+i)*32+l*4+3]<<(7-j)&0x10)

}

else

{

dispram[l*4] =dispram[l*4]&0xff<<(j-7)|flash_word[(flash_heard+i)*32+l*4]>>(15-j)

dispram[l*4+1]=flash_word[(flash_heard+i)*32+l*4]<<(j-7)|(flash_word[(flash_heard+i)*32+l*4+1]>>(15-j))

dispram[l*4+2]=flash_word[(flash_heard+i)*32+l*4+2]<<(15-j)|(flash_word[(flash_heard+i)*32+l*4+3]>>(j-7))

dispram[l*4+3]=(dispram[l*4+3]&0xff>>(j-7))|flash_word[(flash_heard+i)*32+l*4+3]<<(15-j)

}

}

delay(sdu*SPEED)

}

delay(state*SPEED)

}

}

/*******************霓虹灯效果************************/

void flash(uchar *flash_word,uchar flash_heard,uchar number,uchar sdu,uchar state)

{register uchar i,j,k,l

for(i=0i<numberi++)

{

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

{

for(k=17k>jk--)

{

for(l=0l<16l++)

{

if(j>8)

{

dispram[l*2] =1<<(8-k+j)|(flash_word[(flash_heard+i)*32+l*2]&0xff>>(16-j))

dispram[l*2+1]=flash_word[(flash_heard+i)*32+l*2+1]

}

else

{

dispram[l*2]=1<<(8-k+j)

dispram[l*2+1]=1<<(16-k+j)|(flash_word[(flash_heard+i)*32+l*2+1]&0xff>>(8-j))

}

}

delay(sdu*SPEED)

}

for(k=17k>jk--)

{

for(l=0l<16l++)

{

if(j>8)

{

dispram[l*2]=1<<(k-8)|(flash_word[(flash_heard+i)*32+l*2]&0xff>>(16-j))

}

else

{

dispram[l*2]=1<<(k-8)

dispram[l*2+1]=1<<k|(flash_word[(flash_heard+i)*32+l*2+1]&0xff>>(8-j))

}

}

delay(sdu*SPEED)

}

}

delay(state*SPEED)

}

}

/*******************跳动的米奇*********************/

void miqi_jump(void)

{uchar jump_i

while((receive[1]&0x0f)<2)

{

switch (abc/7280)//(receive[0]&0x0f)%9

{

case 0:for(jump_i=0jump_i<16jump_i++)

{

dispram[jump_i*2] = Bmp1[14][jump_i*2]<<1|Bmp1[14][jump_i*2+1]>>7

dispram[jump_i*2+1] = Bmp1[14][jump_i*2+1]<<1//左移

}break

case 1:for(jump_i=0jump_i<15jump_i++)

{dispram[0] = 0

dispram[1] = 0

dispram[jump_i*2+2] = Bmp1[14][jump_i*2]

dispram[jump_i*2+3] = Bmp1[14][jump_i*2+1]}

break//下移

case 2:for(jump_i=0jump_i<16jump_i++)

{

dispram[jump_i*2+1] = Bmp1[14][jump_i*2+1]>>1|Bmp1[14][jump_i*2]<<7

dispram[jump_i*2] = Bmp1[14][jump_i*2]>>1

}break//右移

case 3:for(jump_i=0jump_i<15jump_i++)

{dispram[30] = 0

dispram[31] = 0

dispram[jump_i*2] = Bmp1[14][jump_i*2+2]

dispram[jump_i*2+1] = Bmp1[14][jump_i*2+3]}

break//上移

case 4: for(jump_i=0jump_i<16jump_i++)

{

dispram[jump_i*2+2] = Bmp1[14][jump_i*2]<<1|Bmp1[14][jump_i*2+1]>>7

dispram[jump_i*2+3] = Bmp1[14][jump_i*2+1]<<1//左移

dispram[0] = 0

dispram[1] = 0

} break//下移

case 5: for(jump_i=0jump_i<16jump_i++)

{

dispram[jump_i*2+1] = Bmp1[14][jump_i*2+3]>>1|Bmp1[14][jump_i*2+2]<<7

dispram[jump_i*2] = Bmp1[14][jump_i*2+2]>>1

dispram[30] = 0

dispram[31] = 0

} break//上移

case 6: for(jump_i=0jump_i<16jump_i++)

{

dispram[jump_i*2+3] = Bmp1[14][jump_i*2+1]>>1|Bmp1[14][jump_i*2]<<7

dispram[jump_i*2+2] = Bmp1[14][jump_i*2]>>1

dispram[0] = 0

dispram[1] = 0

}

break

case 7: for(jump_i=0jump_i<16jump_i++)

{

dispram[jump_i*2] = Bmp1[14][jump_i*2+2]<<1|Bmp1[14][jump_i*2+3]>>7

dispram[jump_i*2+1] = Bmp1[14][jump_i*2+3]<<1//左移

dispram[30] = 0

dispram[31] = 0

} break

case 8:for(jump_i=0jump_i<32jump_i++)

dispram[jump_i] = Bmp1[14][jump_i]break

}

}

}

/********从wordsp的第OpenDheard个字开始开门效果显示number个字**********/

//开门效果

void Open_door(uchar wordsp[][32],uchar OpenDheard,uchar number,uchar sdu,uchar state)

{register uchar i,j,w

for(w=0w<numberw++)

{

for(j=1j<9j++)

{

for(i=0i<16i++)

{

dispram[i*2]=dispram[i*2]&0xff<<j|wordsp[OpenDheard+w][2*i]&0xff>>(8-j)

dispram[i*2+1]=dispram[i*2+1]&0xff>>j|wordsp[OpenDheard+w][1+2*i]&0xff<<(8-j)

}

delay(sdu*SPEED)

}

delay(state*TIME)

}

}

/********从wordsp的第CloseDheard个字开始关门效果显示number个字**********/

//关门效果

void Close_door(uchar wordsp[][32],uchar CloseDheard,uchar number,uchar sdu,uchar state)

{register uchar i,j,w

for(w=0w<numberw++)

{

for(j=1j<9j++)

{

for(i=0i<16i++)

{

dispram[i*2]=dispram[i*2]&0xff>>j|wordsp[CloseDheard+w][2*i]&0xff<<(8-j)

dispram[i*2+1]=dispram[i*2+1]&0xff<<j|wordsp[CloseDheard+w][1+2*i]&0xff>>(8-j)

}

delay(sdu*SPEED)

}

delay(state*TIME)

}

}

/********从wordsp的第Far_Awayheard个字开始两边拉开显示number个字**********/

//两边拉开

void Far_Away(uchar wordsp[][32],uchar Far_Awayheard,uchar number,uchar sdu,uchar state)

{register uchar i,j,w

for(w=0w<numberw++)

{

for(j=1j<9j++)

{

for(i=0i<16i++)

{

dispram[i*2]=dispram[i*2]<<j|wordsp[Far_Awayheard+w][2*i]&0xff>>(8-j)

dispram[i*2+1]=dispram[i*2+1]>>j|wordsp[Far_Awayheard+w][1+2*i]&0xff<<(8-j)

}

delay(sdu*SPEED)

}

delay(state*TIME)

}

}

/********从wordsp的第Close_Toheard个字开始两边合拢显示number个字**********/

//两边合拢

void Close_To(uchar wordsp[][32],uchar Close_Toheard,uchar number,uchar sdu,uchar state)

{register uchar i,j,w

for(w=0w<numberw++)

{

for(j=1j<9j++)

{

for(i=0i<16i++)

{

dispram[i*2]=dispram[i*2]&0xff>>j|wordsp[Close_Toheard+w][2*i]<<(8-j)

dispram[i*2+1]=dispram[i*2+1]&0xff<<j|wordsp[Close_Toheard+w][1+2*i]>>(8-j)

}

delay(sdu*SPEED)

}

delay(state*TIME)

}

}

/****************卷帘出显示number个字***************/

//卷帘出显示

void M_Words(uchar *wordsp,uchar MWheard,uchar number,uchar sdu,uchar state)

{register uchar i,w

for(w=0w<numberw++)

{

for(i=0i<32i++)

{

dispram[i]=wordsp[(MWheard+w)*32+i]

if(i%2)

delay(sdu*SPEED)

}

delay(state*TIME)

}

}

/************从UP_Pullp的第UP_Pullheard个字向上拉出number个字***************/

//向上拉出

void UP_Pull_Word(uchar UP_Pullp[][32],uchar UP_Pullheard,uchar number,uchar sdu,uchar state)

{register uchar i,j,k

for(i=0i<numberi++)

{

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

{

for(k=0k<15-jk++)

{

dispram[k*2]=dispram[(k+1)*2]

dispram[k*2+1]=dispram[(k+1)*2+1]

}

dispram[30-2*j]=UP_Pullp[UP_Pullheard+i][(15-j)*2]

dispram[31-2*j]=UP_Pullp[UP_Pullheard+i][(15-j)*2+1]

delay(sdu*SPEED)

}

delay(state*TIME)

}

}

/*********从UPp的第UPheard个字向上滚屏number个字***************/

//向上滚屏

void UP_Run_Word(uchar UPp[][32],uchar UPheard,uchar number,uchar sdu,uchar state)

{register uchar i,j,k

for(i=0i<numberi++)

{

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

{

for(k=0k<15k++)

{

dispram[k*2]=dispram[(k+1)*2]

dispram[k*2+1]=dispram[(k+1)*2+1]

}

dispram[30]=UPp[UPheard+i][j*2]

dispram[31]=UPp[UPheard+i][j*2+1]

delay(sdu*SPEED)

}

delay(state*TIME)

}

}

/*********从Down_Pullp的第Down_Pullheard个字向下拉出number个字***************/

//向下拉出

void Down_Pull_Word(uchar Down_Pullp[][32],uchar Down_Pullheard,uchar number,uchar sdu,uchar state)

{register uchar i,j,k

for(i=0i<numberi++)

{

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

{

for(k=15k>jk--)

{

dispram[k*2]=dispram[(k-1)*2]

dispram[k*2+1]=dispram[(k-1)*2+1]

}

dispram[2*j]=Down_Pullp[Down_Pullheard+i][2*j]

dispram[2*j+1]=Down_Pullp[Down_Pullheard+i][2*j+1]

delay(sdu*SPEED)

}

delay(state*TIME)

}

}

/*********从Downp的第UPheard个字向下滚屏number个字***************/

//向下滚屏

void Down_Run_Word(uchar *Downp,uchar UPheard,uchar number,uchar sdu,uchar state)

{register uchar i,j,k

for(i=0i<numberi++)

{

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

{

for(k=15k>0k--)

{

dispram[k*2]=dispram[(k-1)*2]

dispram[k*2+1]=dispram[(k-1)*2+1]

}

dispram[0]=Downp[(UPheard+i)*32+(15-j)*2]

dispram[1]=Downp[(UPheard+i)*32+(15-j)*2+1]

delay(sdu*SPEED)

}

delay(state*TIME)

}

}

/**********从LRp的第LRheard个字左移出显示number个字************/

//用左移出显示

void L_Removeout_Word(uchar *LRp,uchar LRheard,uchar number,uchar sdu,uchar state)

{register uchar i,j,k,l

for(i=0i<numberi++)

{

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

for(k=0k<8k++)

{

for(l=0l<16l++)

{

dispram[l*2]=dispram[l*2]<<1|dispram[l*2+1]>>7

dispram[l*2+1]=dispram[l*2+1]<<1|LRp[(i+LRheard)*32+l*2+j]>>(7-k)

}

delay(sdu*SPEED)

}

delay(state*TIME)

}

}

/**********从L_Pullp的第L_Pullheard个字左拉出显示number个字************/

//左拉出显示

void L_Pull_Word(uchar *L_Pullp,uchar L_Pullheard,uchar number,uchar sdu,uchar state)

{register uchar i,j,k,l

for(i=0i<numberi++)

{

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

for(k=0k<8k++)

{

for(l=0l<16l++)

{

if(j==0)

{

dispram[l*2]=dispram[l*2]<<1|dispram[l*2+1]>>7

dispram[l*2+1]=(dispram[l*2+1]&0xff<<(k+1))<<1|L_Pullp[(i+L_Pullheard)*32+l*2+1]&0xff>>(7-k)

}

else

{

dispram[l*2]=(dispram[l*2]&0xff<<(k+1))<<1|L_Pullp[(i+L_Pullheard)*32+l*2]&0xff>>(7-k)

dispram[l*2+1]=L_Pullp[(i+L_Pullheard)*32+l*2+1]

}

}

delay(sdu*SPEED)

}

delay(state*TIME)

}

}

/****************卷帘出黑屏***************/

void M_Black(void)

{register uchar i

for(i=0i<32i++)

{

dispram[i]=0x00

if(i%2)

delay(5*SPEED)

}

}

/**********从RRp的第RRheard个字右移出显示number个字************/

//右移出显示

void R_Removeout_Word(uchar *RRp,uchar RRheard,uchar number,uchar sdu,uchar state)

{register uchar i,j,k,l

for(i=0i<numberi++)

{

for(j=2j>0j--)

for(k=0k<8k++)

{

for(l=0l<16l++)

{

dispram[l*2+1]=dispram[l*2+1]>>1|dispram[l*2]<<7

dispram[l*2]=dispram[l*2]>>1|RRp[(i+RRheard)*32+l*2+j-1]<<(7-k)

}

delay(sdu*SPEED)

}

delay(state*TIME)

}

}

/**************随机跑动函数**************/

void radom_flash(uchar *Radom_p,uchar Radom_heard,uchar number,uchar sdu,uchar state)

{

switch ((receive[1]&0x0f)+(receive[0]&0x70)/16)

{

case 0: Open_door(Radom_p,Radom_heard,number,sdu,state)M_Black()break//开门

case 1: Close_door(Radom_p,Radom_heard,number,sdu,state)M_Black()break//关门

case 2: Far_Away(Radom_p,Radom_heard,number,sdu,state)M_Black()break//分开

case 3: Close_To(Radom_p,Radom_heard,number,sdu,state)M_Black()break//合拢

case 4: miqi_jump()

case 5: M_Words(Radom_p,Radom_heard,number,sdu,state)M_Black()break//卷帘

case 6: UP_Pull_Word(Radom_p,Radom_heard,number,sdu,state)break//上拉出

case 7: UP_Run_Word(Radom_p,Radom_heard,number,sdu,state)break//上滚屏

case 8: Down_Pull_Word(Radom_p,Radom_heard,number,sdu,state)break//下拉出

case 9: Down_Run_Word(Radom_p,Radom_heard,number,sdu,state)break

case 10: L_Removeout_Word(Radom_p,Radom_heard,number,sdu,state)break//左滚屏

case 11: L_Pull_Word(Radom_p,Radom_heard,number,sdu,state)break//左拉出

case 12: R_Removeout_Word(Radom_p,Radom_heard,number,sdu,state)break//右滚屏

case 13: flash(Radom_p,Radom_heard,number,3,state)break

case 14: flash_bai(Radom_p,Radom_heard,number,sdu,state)break

}

}

#include<reg1.h>

void main(void)

{

P0 =0X00

P2 =0X00

while(1)

}

这样就亮了,

程序就是这样几句,

你也太抠门了 为了画电路图方便省去了电阻,你应该直接省去所有东西 然后睡大觉去


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

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

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

发表评论

登录后才能评论

评论列表(0条)

保存