-
Notifications
You must be signed in to change notification settings - Fork 2
/
modified_shiftOutBG.ino
67 lines (53 loc) · 1.39 KB
/
modified_shiftOutBG.ino
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
const int latchPin1 = 8; //red latch
const int latchPin2 = 9; //blue green latch
const int clockPin = 12;
const int dataPin1 = 11; //red blue
const int dataPin2 = 13; //green
const int dataPin3 = 10; //blue(not connected)
byte arr_red[] = {0x00,0x80};
byte arr_green[] = {0x00, 0x40};
byte arr_blue[] = {0x00, 0x20};
void shiftOutBG(uint8_t dpb, uint8_t dpg, uint8_t clkp, uint8_t btordr, uint8_t valb, uint8_t valg){
uint8_t i;
for (i = 0; i < 8; i++) {
if (btordr == LSBFIRST) {
digitalWrite(dpb, valb & 1);
valb >>= 1;
} else {
digitalWrite(dpb, (valb & 128) != 0);
valb <<= 1;
}
if (btordr == LSBFIRST) {
digitalWrite(dpg, valg & 1);
valg >>= 1;
} else {
digitalWrite(dpg, (valg & 128) != 0);
valg <<= 1;
}
digitalWrite(clockPin, HIGH);
digitalWrite(clockPin, LOW);
}
}
void rgb_clm(){
digitalWrite(latchPin2, LOW);
for(int i=0; i<2; i++){
shiftOutBG(dataPin1, dataPin2, clockPin, MSBFIRST, arr_blue[i], arr_green[i]);
}
digitalWrite(latchPin2, HIGH);
digitalWrite(latchPin1, LOW);
for(int k=0; k<2; k++){
shiftOut(dataPin1, clockPin, MSBFIRST, arr_red[k]);
}
digitalWrite(latchPin1, HIGH);
}
void setup() {
pinMode(latchPin1, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin1, OUTPUT);
pinMode(latchPin2,OUTPUT);
pinMode(dataPin2, OUTPUT);
pinMode(dataPin3,OUTPUT);
rgb_clm();
}
void loop() {
}