Skip to content

Instantly share code, notes, and snippets.

Created May 1, 2012 01:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/2564292 to your computer and use it in GitHub Desktop.
Save anonymous/2564292 to your computer and use it in GitHub Desktop.
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