极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 14981|回复: 4

请教关于函数shiftOut(dataPin, clockPin, bitOrder, value)的使用

[复制链接]
发表于 2012-12-6 16:19:49 | 显示全部楼层 |阅读模式
本帖最后由 swim 于 2012-12-6 19:58 编辑

看这个教程时,对于函数shiftOut(dataPin, clockPin, bitOrder, value)不明白,请教通俗的解说,尤其是value倒底是干嘛用的
。还有 for (int j = 0; j < 256; j++) 为什么要循环256次。跟value有什么关系?谢谢啦


  1. //**************************************************************//
  2. //  Name    : shiftOutCode, Hello World                         //
  3. //  Author  : Carlyn Maw,Tom Igoe                               //
  4. //  Date    : 25 Oct, 2006                                      //
  5. //  Version : 1.0                                               //
  6. //  Notes   : Code for using a 74HC595 Shift Register           //
  7. //          : to count from 0 to 255                            //
  8. //****************************************************************

  9. //Pin connected to ST_CP of 74HC595
  10. int latchPin = 8;
  11. //Pin connected to SH_CP of 74HC595
  12. int clockPin = 12;
  13. ////Pin connected to DS of 74HC595
  14. int dataPin = 11;

  15. void setup() {
  16.    //set pins to output because they are addressed in the main loop
  17.    pinMode(latchPin, OUTPUT);
  18.    pinMode(clockPin, OUTPUT);
  19.    pinMode(dataPin, OUTPUT);
  20. }

  21. void loop() {
  22.       
  23.   for (int j = 0; j < 256; j++) {
  24.      
  25.    digitalWrite(latchPin, LOW);
  26.      shiftOut(dataPin, clockPin, LSBFIRST, j);   //MSBFIRST  LSBFIRST
  27.    
  28.     digitalWrite(latchPin, HIGH);
  29.      delay(300);
  30.    }
  31. }


复制代码
回复

使用道具 举报

 楼主| 发表于 2012-12-6 17:31:12 | 显示全部楼层
此函数已明白,顺便问下怎样让主题显示已解决的标签?
回复 支持 反对

使用道具 举报

发表于 2012-12-6 18:37:24 | 显示全部楼层
等斑竹给你改
回复 支持 反对

使用道具 举报

发表于 2014-12-4 16:27:33 | 显示全部楼层
看懂了。知道思路和原理饿了
回复 支持 反对

使用道具 举报

发表于 2014-12-8 19:05:15 | 显示全部楼层
请问,如果将256成别的数字会怎样,我不太理解。。。
回复 支持 反对

使用道具 举报

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

本版积分规则

Archiver|联系我们|极客工坊

GMT+8, 2026-6-8 06:19 , Processed in 0.036208 second(s), 21 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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