Go Down

### Topic: shiftOut changes to Tutorial (Read 414 times)previous topic - next topic

#### 8bit

##### Feb 08, 2015, 09:50 pm
Hi everyone, i don`t know if this is the right place to post this.
Actually i`m working first time with a 8bit shiftRegister and found your tutorial really good, as all of them ... (http://arduino.cc/en/Tutorial/ShiftOut).
In the tutorial there is a Code Sample 1.3 Using an array:(http://arduino.cc/en/Tutorial/ShftOut13).
There I found this information, that is not correct - as i think:

//Arduino doesn't seem to have a way to write binary straight into the code
//so these values are in HEX.  Decimal would have been fine, too.
dataArray[0] = 0xFF; //11111111
...

In another Project with NeoPixels i used the following way for this problem (there I used multidimensional arrays), maybe its nice for other nonExperts like me, to know, that thereĀ“s another, maybe simpler way to do this. Maybe you`ll wanna change the tutorial, if you like the idea. As you like, i could comment the code, that other people will understand it better (if they have not very much coding skills - like me) ...

Code: [Select]
`//Pin connected to ST_CP of 74HC595int latchPin = 8;//Pin connected to SH_CP of 74HC595int clockPin = 12;////Pin connected to DS of 74HC595int dataPin = 11;//holders for infromation you're going to pass to shifting functionbyte dataArray[10]={  B10101010,  B00000000,  B10101010,  B00000000,  B11001100,  B00000000,  B11101110,  B00000000,  B11001100,  B00000000};void setup() {  pinMode(latchPin, OUTPUT);  pinMode(clockPin, OUTPUT);  pinMode(dataPin, OUTPUT);  Serial.begin(9600);}void loop() {  outputSequence(dataArray);}void outputSequence(byte sequence[]){  for (int j = 0; j < 10; j++) {    digitalWrite(latchPin, 0);    shiftOut(dataPin, clockPin, MSBFIRST, sequence[j]);    digitalWrite(latchPin, 1);    delay(350);  }}`

#### prosperkatula

#1
##### Feb 09, 2015, 05:57 am
thanks for the correction

Go Up