Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define PIN_CLK 2
- #define PIN_ADD0 3
- #define PIN_ADD1 4
- #define PIN_OE 5
- #define PIN_LAT 6
- #define PIN_D1 7
- #define PIN_D2 8
- int ct = 0; // test counter
- void setup() {
- for (int i = 0; i < 7; i ++) {
- pinMode(2 + i, OUTPUT);
- digitalWrite(2 + i, LOW);
- }
- digitalWrite(PIN_OE, LOW);
- // test 1
- // set A0 and A1 to 0 0
- // controls bank to push vals to.
- // 3
- // 2
- // 1
- // 0
- // etc
- digitalWrite(PIN_ADD0, 0);
- digitalWrite(PIN_ADD1, 0);
- // each bank consists of 128 leds
- // d1 is data for bottom half of display
- // d2 is data for top half
- // shifting data:
- // each bank is further split into chunks
- // 0 pixel is bottom right, proceeds to left until hitting 8
- // row then changes to row+4 and continues from column 0
- // colour then changes to next in cycle
- // data is BBBBBBBB BBBBBBBB GGGGGGGG GGGGGGGG RRRRRRRR RRRRRRRR
- // | row 0 | row 4 | row 0 | row 4 | row 0 | row 4
- }
- void loop() {
- //turn off display
- digitalWrite(PIN_OE, HIGH);
- //set latch low to send data
- digitalWrite(PIN_LAT, LOW);
- ct++;
- ct %= 384;
- //think of each bank as 384 alternating rgb leds. Turn each one on in turn
- // this will do both upper and lower panels at the same time
- for (int i = 0; i < 384; i++) { // led index
- if (i == ct) {
- digitalWrite(PIN_D1, 1);
- digitalWrite(PIN_D2, 1);
- } else {
- digitalWrite(PIN_D1, 0);
- digitalWrite(PIN_D2, 0);
- }
- // toggle clock
- digitalWrite(PIN_CLK, LOW);
- digitalWrite(PIN_CLK, HIGH);
- }
- // flip the latch
- digitalWrite(PIN_LAT, HIGH);
- digitalWrite(PIN_LAT, LOW);
- // turn on display
- digitalWrite(PIN_OE, LOW);
- delay(200);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement