Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int datapin = 2;
- int clockpin = 3;
- int latchpin = 4;
- uint16_t data = 0;
- void setup()
- {
- pinMode(datapin, OUTPUT);
- pinMode(clockpin, OUTPUT);
- pinMode(latchpin, OUTPUT);
- }
- void loop()
- {
- oneOnAtATime(); // Scroll down the line
- }
- void shiftWrite(int desiredPin, boolean desiredState)
- {
- digitalWrite(latchpin, LOW);
- if(desiredState)
- data |= (1<<desiredPin);
- else
- data &= ~(1<<desiredPin);
- shiftOut(datapin, clockpin, MSBFIRST, data>>8);
- shiftOut(datapin, clockpin, MSBFIRST, data);
- digitalWrite(latchpin, HIGH);
- }
- void oneOnAtATime()
- {
- int i;
- int delayTime = 1000;
- int myArray[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
- for(i=0; i<16; i++)
- {
- shiftWrite(myArray[i], HIGH); // turn LED on
- delay(delayTime); // pause to slow down the sequence
- shiftWrite(myArray[i], LOW);// turn LED off
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement