极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 10652|回复: 0

一位数码管使用74hc595 点亮运行

[复制链接]
发表于 2014-9-14 23:54:32 | 显示全部楼层 |阅读模式
  1. int st_cp = 8;
  2. int sh_cp = 12;
  3. int ds = 11; //这里定义了那三个脚


  4. int n0=63;
  5. int n1=6;
  6. int n2=91;
  7. int n3=79;
  8. int n4=102;
  9. int n5=109;
  10. int n6=125;
  11. int n7=7;
  12. int n8=127;
  13. int n9=111;
  14. int n10=128;
  15. int a[11]={n0, n1,n2,n3,n4,n5,n6,n7,n8,n9 ,n10};

  16. void setup ()
  17. {
  18.   pinMode(st_cp,OUTPUT);
  19.   pinMode(sh_cp,OUTPUT);
  20.   pinMode(ds,OUTPUT); //让三个脚都是输出状态
  21. }
  22. void loop()
  23. {
  24.        
  25. for( int i =0 ;i<=10 ; i++){

  26.         digitalWrite(st_cp,LOW); //将ST_CP口上面加低电平让芯片准备好接收数据


  27.     shiftOut(ds,sh_cp,LSBFIRST,a[i]);

  28.     digitalWrite(st_cp,HIGH); //将ST_CP这个针脚恢复到高电平


  29.     delay(200);
  30. }

  31.    
  32. }
复制代码

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|联系我们|极客工坊

GMT+8, 2026-6-15 04:32 , Processed in 0.063443 second(s), 18 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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