标题: 视频:单片机数码管滚动显示“I Love You”程序源代码 [打印本页]

作者: niujia    时间: 2015-7-15 23:20
标题: 视频:单片机数码管滚动显示“I Love You”程序源代码
视频演示:
http://player.youku.com/player.php/sid/XMzMzNTE3OTg4/v.swf

数码管显示部分的原理图(只看显示部分):http://www.51hei.com/f/51hei-5.pdf

程序源代码:
  1. #include<reg51.h>
  2. #include<intrins.h>
  3. #define uchar unsigned char
  4. #define uint  unsigned int
  5. sbit wela=P2^7;
  6. sbit dula=P2^6;
  7. uchar code duanma[]={0x06,0x00,0x38,0x3f,0x3e,0x79,0x00,0x6e,0x3f,0xbe,0x00};
  8. uchar code weima[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
  9. uchar smg_change[11];
  10. void display(uchar f,uchar n )
  11. {
  12. static uchar i;
  13. P0=0X00;
  14. dula=1;dula=0;

  15. P0=weima[f+i];
  16. wela=1;wela=0;

  17. P0=smg_change[i];
  18. dula=1;dula=0;
  19. i++;
  20. if(i==n)
  21. i=0;
  22. }
  23. void jiaohuan()
  24. {
  25. uchar i,dd;
  26. for(i=0;i<10;i++)
  27. {
  28.   dd=smg_change[i];
  29.   smg_change[i]=smg_change[i+1];
  30.   smg_change[i+1]=dd;
  31. }
  32. }
  33. void main()
  34. {
  35. uchar y,i;
  36. uint t;
  37. for(i=0;i<11;i++)
  38. {
  39.   smg_change[i]=duanma[i];
  40. }
  41. while(1)
  42. {
  43.     display(y,6);
  44.     t++;
  45.     if(t==10000)
  46.     {  t=0;
  47.        jiaohuan();
  48.     }
  49. }
  50. }
复制代码





作者: 腾飞的龙    时间: 2015-7-23 14:36
感谢分享,很好的创意!




欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1