Guest User

Untitled

a guest
Mar 29th, 2017
135
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define PIN_CLK 2
  2. #define PIN_ADD0 3
  3. #define PIN_ADD1 4
  4. #define PIN_OE 5
  5. #define PIN_LAT 6
  6. #define PIN_D1 7
  7. #define PIN_D2 8
  8.  
  9.  
  10. int ct = 0; // test counter
  11.  
  12. void setup() {
  13. for (int i = 0; i < 7; i ++) {
  14. pinMode(2 + i, OUTPUT);
  15. digitalWrite(2 + i, LOW);
  16. }
  17. digitalWrite(PIN_OE, LOW);
  18.  
  19. // test 1
  20. // set A0 and A1 to 0 0
  21. // controls bank to push vals to.
  22. // 3
  23. // 2
  24. // 1
  25. // 0
  26. // etc
  27. digitalWrite(PIN_ADD0, 0);
  28. digitalWrite(PIN_ADD1, 0);
  29. // each bank consists of 128 leds
  30. // d1 is data for bottom half of display
  31. // d2 is data for top half
  32.  
  33. // shifting data:
  34. // each bank is further split into chunks
  35. // 0 pixel is bottom right, proceeds to left until hitting 8
  36. // row then changes to row+4 and continues from column 0
  37. // colour then changes to next in cycle
  38. // data is BBBBBBBB BBBBBBBB GGGGGGGG GGGGGGGG RRRRRRRR RRRRRRRR
  39. // | row 0 | row 4 | row 0 | row 4 | row 0 | row 4
  40.  
  41. }
  42.  
  43. void loop() {
  44. //turn off display
  45. digitalWrite(PIN_OE, HIGH);
  46. //set latch low to send data
  47. digitalWrite(PIN_LAT, LOW);
  48. ct++;
  49. ct %= 384;
  50.  
  51. //think of each bank as 384 alternating rgb leds. Turn each one on in turn
  52. // this will do both upper and lower panels at the same time
  53. for (int i = 0; i < 384; i++) { // led index
  54. if (i == ct) {
  55. digitalWrite(PIN_D1, 1);
  56. digitalWrite(PIN_D2, 1);
  57. } else {
  58. digitalWrite(PIN_D1, 0);
  59. digitalWrite(PIN_D2, 0);
  60.  
  61. }
  62. // toggle clock
  63. digitalWrite(PIN_CLK, LOW);
  64. digitalWrite(PIN_CLK, HIGH);
  65.  
  66. }
  67.  
  68.  
  69.  
  70. // flip the latch
  71. digitalWrite(PIN_LAT, HIGH);
  72. digitalWrite(PIN_LAT, LOW);
  73.  
  74. // turn on display
  75. digitalWrite(PIN_OE, LOW);
  76.  
  77. delay(200);
  78. }
RAW Paste Data