int value;
int x;
#define BUTTON 13
const int buttonPin = 13;
const int ledPin = 11;
const int ledPin2 = 10;
int buttonState13 = 0;
#define dataPin 12 //serial
#define latchPin 11 //latch pin
#define clockPin 10 //clock
int afr = 0;
uint32_t LEDfull = 0x0;
const int LED00[] = {0xEE, 0x22, 0x7C, 0x76, 0xB2, 0xD6, 0xDE, 0x62, 0xFE, 0xF6};
const int LED10[] = {0xEE00, 0x2200, 0x7C00, 0x7600, 0xB200, 0xD600, 0xDE00, 0x6200, 0xFE00, 0xF600};
const int LED20[] = {0xEE0000, 0x220000, 0x7C0000, 0x760000, 0xB20000, 0xD60000, 0xDE0000, 0x620000, 0xFE0000, 0xF60000};
const int LED30[] = {0x00000000, 0x22000000, 0x7C000000, 0x76000000, 0xB2000000, 0xD6000000, 0xDE000000, 0x62000000, 0xFE000000, 0xF6000000, 0xEE000000};
const int LEDS0 = 0x10000;
void updateShiftRegister(unsigned long leds, bool isMSBFIRST = true){
unsigned int leds16 = int(leds);
unsigned int leds32 = int(leds>>16);
byte low16LED = lowByte(leds16);
byte high16LED = highByte(leds16);
byte low32LED = lowByte(leds32);
byte high32LED = highByte(leds32);
digitalWrite(latchPin, LOW);
if (isMSBFIRST == false) {
shiftOut(dataPin, clockPin, LSBFIRST, low16LED);
shiftOut(dataPin, clockPin, LSBFIRST, high16LED);
shiftOut(dataPin, clockPin, LSBFIRST, low32LED);
shiftOut(dataPin, clockPin, LSBFIRST, high32LED);
}
else {
shiftOut(dataPin, clockPin, MSBFIRST, high32LED);
shiftOut(dataPin, clockPin, MSBFIRST, low32LED);
shiftOut(dataPin, clockPin, MSBFIRST, high16LED);
shiftOut(dataPin, clockPin, MSBFIRST, low16LED);
}
digitalWrite(latchPin, HIGH);
}
void setup() {
randomSeed(2);
Serial.begin(9600);
x = 0;
pinMode(dataPin, OUTPUT);
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
}
void loop() {
afr = (afr + 1) % 10;
LEDfull=LED30[afr]+LED20[afr]+LED10[afr]+LED00[afr]+LEDS0;
Serial.println(afr);
delay(500);
LEDfull=LED30[afr]+LED20[afr]+LED10[afr]+LED00[afr];
updateShiftRegister(LEDfull);
delay(500);}