-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebug-32leds.c
30 lines (26 loc) · 1.01 KB
/
debug-32leds.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/*
The purpose of this code is only to check if all the components
are working accordingly.
It will just light some LEDs based on the 'data' variable.
Note that 'data' was initialized using binary notation for a better
view of which LED will be on or off. It could be initialized using
hexdecimal or decimal notation as well.
*/
int latchPin = 8;
int clockPin = 12;
int dataPin = 11;
void setup() {
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
}
void loop() {
unsigned long int data = 0b11001100101010100011001101010101; // 0xCCAA3355 or 3433706325
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, data); // shiftOut works with 8 bits.
shiftOut(dataPin, clockPin, LSBFIRST, data >> 8); // we need to shift data
shiftOut(dataPin, clockPin, LSBFIRST, data >> 16); // to send all the 32 bits to
shiftOut(dataPin, clockPin, LSBFIRST, data >> 24); // the 4 x shift register IC (74hc595)
digitalWrite(latchPin, HIGH);
delay(1500);
}