ch00148070 发表于 2012-12-6 16:19:49

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

本帖最后由 swim 于 2012-12-6 19:58 编辑

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


//**************************************************************//
//Name    : shiftOutCode, Hello World                         //
//Author: Carlyn Maw,Tom Igoe                               //
//Date    : 25 Oct, 2006                                    //
//Version : 1.0                                             //
//Notes   : Code for using a 74HC595 Shift Register         //
//          : to count from 0 to 255                            //
//****************************************************************

//Pin connected to ST_CP of 74HC595
int latchPin = 8;
//Pin connected to SH_CP of 74HC595
int clockPin = 12;
////Pin connected to DS of 74HC595
int dataPin = 11;

void setup() {
   //set pins to output because they are addressed in the main loop
   pinMode(latchPin, OUTPUT);
   pinMode(clockPin, OUTPUT);
   pinMode(dataPin, OUTPUT);
}

void loop() {
      
for (int j = 0; j < 256; j++) {
   
   digitalWrite(latchPin, LOW);
   shiftOut(dataPin, clockPin, LSBFIRST, j);   //MSBFIRSTLSBFIRST
   
    digitalWrite(latchPin, HIGH);
   delay(300);
   }
}


ch00148070 发表于 2012-12-6 17:31:12

此函数已明白,顺便问下怎样让主题显示已解决的标签?

test01 发表于 2012-12-6 18:37:24

等斑竹给你改

menghuyouyou 发表于 2014-12-4 16:27:33

看懂了。知道思路和原理饿了

winking 发表于 2014-12-8 19:05:15

请问,如果将256成别的数字会怎样,我不太理解。。。
页: [1]
查看完整版本: 请教关于函数shiftOut(dataPin, clockPin, bitOrder, value)的使用