Created
May 1, 2012 01:43
-
-
Save anonymous/2564292 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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