Create a gist now

Instantly share code, notes, and snippets.

anonymous /gist:2564292
Created May 1, 2012

What would you like to do?
const int latchPin = 8;
const int clockPin = 12;
const int dataPin = 11;
char inputString[2];
int arreglo[] = {2,4,6,8,10,12,14};
unsigned int bitsToSend = 0;
void setup() {
pinMode(latchPin, OUTPUT);
pinMode(dataPin, OUTPUT);
pinMode(clockPin, OUTPUT);
Serial.begin(9600);
Serial.println("reset");
}
void loop() {
for(int pos = 0; pos<7; pos++){
registerWrite(arreglo[pos]);
delay(200);
}
}
void registerWrite(int pos) {
digitalWrite(latchPin, LOW);
bitWrite(bitsToSend, pos, HIGH);
byte registerOne = highByte(bitsToSend);
byte registerTwo = lowByte(bitsToSend);
shiftOut(dataPin, clockPin, MSBFIRST, registerTwo);
shiftOut(dataPin, clockPin, MSBFIRST, registerOne);
digitalWrite(latchPin, HIGH);
delay(300);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment