|
|
本帖最后由 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); //MSBFIRST LSBFIRST
-
- digitalWrite(latchPin, HIGH);
- delay(300);
- }
- }
-
复制代码 |
|