-
Notifications
You must be signed in to change notification settings - Fork 0
/
step-3-sample-code.txt
35 lines (27 loc) · 1.39 KB
/
step-3-sample-code.txt
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
31
32
33
34
35
const int strobePin = 8;
const int clockPin = 9;
const int dataPin = 10;
void setup()
{
pinMode(strobePin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
// set up our pins as OUTPUTs
digitalWrite(strobePin, LOW); //set the strobe low so it'll accept instruction
shiftOut(dataPin, clockPin, LSBFIRST, 0x8F); // send the instruction to activate the board and set brightness to max
digitalWrite(strobePin, HIGH); //we will always set the strobe high after the completion of each instruction and data set
// ***sequential addressing example
digitalWrite(strobePin, LOW); //strobe goes low to load an instruction
shiftOut(dataPin, clockPin, LSBFIRST, 0x40); // set up sequential addressing mode
digitalWrite(strobePin, HIGH); // end of instruction, strobe must go high
digitalWrite(strobePin, LOW); // strobe goes low to receive the data
shiftOut(dataPin, clockPin, LSBFIRST, 0xC0); // sets up the first address
shiftOut(dataPin, clockPin, LSBFIRST, 0x77); // sets up a 7 segment "A"
shiftOut(dataPin, clockPin, LSBFIRST, 0x00); // turns off discrete LED
shiftOut(dataPin, clockPin, LSBFIRST, 0x77); // sets up a 7 segment "A"
shiftOut(dataPin, clockPin, LSBFIRST, 0x01); // turns on discrete LED
digitalWrite(strobePin, HIGH); // end of data, strobe goes high
}
void loop() {
// put your main code here, to run repeatedly:
}