Hi everyone, i dont 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) ...
//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;
//holders for infromation you're going to pass to shifting function
byte 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);
}
}