-
Notifications
You must be signed in to change notification settings - Fork 0
/
step-4-sample-code.txt
39 lines (31 loc) · 1.67 KB
/
step-4-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
36
37
38
39
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 wrap-around example.
digitalWrite(strobePin, LOW); //set strobe low for an instruction
shiftOut(dataPin, clockPin, LSBFIRST, 0x40); //set up sequential addressing
digitalWrite(strobePin, HIGH); //end of instruction, strobe must go high
digitalWrite(strobePin, LOW); //start of data, strobe must go low
shiftOut(dataPin, clockPin, LSBFIRST, 0xCA); // sets up the first address
shiftOut(dataPin, clockPin, LSBFIRST, 0xFF); // sets up a 7 segment "A"
shiftOut(dataPin, clockPin, LSBFIRST, 0x01); // turns on discrete LED
shiftOut(dataPin, clockPin, LSBFIRST, 0xFF); // sets up a 7 segment "A"
shiftOut(dataPin, clockPin, LSBFIRST, 0x01); // turns on discrete LED
shiftOut(dataPin, clockPin, LSBFIRST, 0xFF); // sets up a 7 segment "A"
shiftOut(dataPin, clockPin, LSBFIRST, 0x01); // turns on discrete LED
shiftOut(dataPin, clockPin, LSBFIRST, 0xFF); // sets up a 7 segment "A"
shiftOut(dataPin, clockPin, LSBFIRST, 0x01); // turns on discrete LED
digitalWrite(strobePin, HIGH); // end of all data, strobe must go high
}
void loop() {
// put your main code here, to run repeatedly:
}