Advertisement
Guest User

Untitled

a guest
Apr 21st, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.70 KB | None | 0 0
  1. #include <Adafruit_NeoPixel.h>
  2. #ifdef __AVR__
  3. #include <avr/power.h>
  4. #endif
  5.  
  6. #define PIN_NFC 1
  7. #define PIN_ACTIVATION 7
  8. #define PIN_PATHWAY1 9
  9. #define PIN_ELEVATOR 10
  10. #define PIN_CHASE 11
  11. #define PIN_PATHWAY2 12
  12. #define PIN_COLORIZER A1
  13.  
  14. #define NUM_NFC 22
  15. #define NUM_ACTIVATION 116
  16. #define NUM_PATHWAY1 128
  17. #define NUM_ELEVATOR 298
  18. #define NUM_CHASE 53
  19. #define NUM_PATHWAY2 65
  20. #define NUM_COLORIZER 255
  21.  
  22. #define BRIGHTNESS 100
  23.  
  24. const int numOfBytes = 298;
  25.  
  26. Adafruit_NeoPixel strip_nfc = Adafruit_NeoPixel(NUM_NFC, PIN_NFC, NEO_GRBW + NEO_KHZ800);
  27. Adafruit_NeoPixel strip_activation = Adafruit_NeoPixel(NUM_ACTIVATION, PIN_ACTIVATION, NEO_GRBW + NEO_KHZ800);
  28. Adafruit_NeoPixel strip_pathway1 = Adafruit_NeoPixel(NUM_PATHWAY1, PIN_PATHWAY1, NEO_GRBW + NEO_KHZ800);
  29. Adafruit_NeoPixel strip_elevator = Adafruit_NeoPixel(NUM_ELEVATOR, PIN_ELEVATOR, NEO_GRBW + NEO_KHZ800);
  30. Adafruit_NeoPixel strip_chase = Adafruit_NeoPixel(NUM_CHASE, PIN_CHASE, NEO_GRBW + NEO_KHZ800);
  31. Adafruit_NeoPixel strip_pathway2 = Adafruit_NeoPixel(NUM_PATHWAY2, PIN_PATHWAY2, NEO_GRBW + NEO_KHZ800);
  32. Adafruit_NeoPixel strip_colorizer = Adafruit_NeoPixel(NUM_COLORIZER, PIN_COLORIZER, NEO_GRBW + NEO_KHZ800);
  33.  
  34. char inputBuffer[numOfBytes];
  35.  
  36. byte neopix_gamma[] = {
  37. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  38. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
  39. 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2,
  40. 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5,
  41. 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10,
  42. 10, 10, 11, 11, 11, 12, 12, 13, 13, 13, 14, 14, 15, 15, 16, 16,
  43. 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 24, 24, 25,
  44. 25, 26, 27, 27, 28, 29, 29, 30, 31, 32, 32, 33, 34, 35, 35, 36,
  45. 37, 38, 39, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 50,
  46. 51, 52, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 66, 67, 68,
  47. 69, 70, 72, 73, 74, 75, 77, 78, 79, 81, 82, 83, 85, 86, 87, 89,
  48. 90, 92, 93, 95, 96, 98, 99,101,102,104,105,107,109,110,112,114,
  49. 115,117,119,120,122,124,126,127,129,131,133,135,137,138,140,142,
  50. 144,146,148,150,152,154,156,158,160,162,164,167,169,171,173,175,
  51. 177,180,182,184,186,189,191,193,196,198,200,203,205,208,210,213,
  52. 215,218,220,223,225,228,231,233,236,239,241,244,247,249,252,255 };
  53.  
  54.  
  55. void setup() {
  56. strip_nfc.setBrightness(BRIGHTNESS);
  57. strip_activation.setBrightness(BRIGHTNESS);
  58. strip_pathway1.setBrightness(BRIGHTNESS);
  59. strip_elevator.setBrightness(BRIGHTNESS);
  60. strip_chase.setBrightness(BRIGHTNESS);
  61. strip_pathway2.setBrightness(BRIGHTNESS);
  62. strip_colorizer.setBrightness(BRIGHTNESS);
  63.  
  64. strip_nfc.begin();
  65. strip_activation.begin();
  66. strip_pathway1.begin();
  67. strip_elevator.begin();
  68. strip_chase.begin();
  69. strip_pathway2.begin();
  70. strip_colorizer.begin();
  71.  
  72. delay(500);
  73. Serial.begin(115200);
  74. Serial.setTimeout(500);
  75.  
  76. strip_nfc.show();
  77. strip_activation.show();
  78. strip_pathway1.show();
  79. strip_elevator.show();
  80. strip_chase.show();
  81. strip_pathway2.show();
  82. strip_colorizer.show();
  83. }
  84.  
  85. void loop() {
  86.  
  87. if(Serial.available() > 0) {
  88. Serial.readBytes(inputBuffer, numOfBytes);
  89. }
  90. if(inputBuffer[0] == 0){
  91. for (int j= 0; j < NUM_NFC; j++) {
  92. int r = inputBuffer[(j*3)+1];
  93. int g = inputBuffer[(j*3)+2];
  94. int b = inputBuffer[(j*3)+3];
  95. int w = min (r, min(g, b));
  96. r = r- w;
  97. g = g - w;
  98. b = b - w;
  99. strip_nfc.setPixelColor(j, r, g, b, w);
  100. strip_nfc.show();
  101. }
  102. }
  103. if(inputBuffer[0] == 1){
  104. for (int j = 0; j < NUM_NFC+NUM_ACTIVATION; j++) {
  105. int r = inputBuffer[(j*3)+1];
  106. int g = inputBuffer[(j*3)+2];
  107. int b = inputBuffer[(j*3)+3];
  108. int w = min (r, min(g, b));
  109. r = r- w;
  110. g = g - w;
  111. b = b - w;
  112. strip_activation.setPixelColor(j, r, g, b, w);
  113. strip_activation.show();
  114. }
  115. }
  116. if(inputBuffer[0] == 2){
  117. for (int j = 0; j < NUM_NFC+NUM_PATHWAY1; j++) {
  118. int r = inputBuffer[(j*3)+1];
  119. int g = inputBuffer[(j*3)+2];
  120. int b = inputBuffer[(j*3)+3];
  121. int w = min (r, min(g, b));
  122. r = r- w;
  123. g = g - w;
  124. b = b - w;
  125. strip_pathway1.setPixelColor(j, r, g, b, w);
  126. strip_pathway1.show();
  127. }
  128. }
  129. if(inputBuffer[0] == 3){
  130. for (int j = 0; j < NUM_NFC+NUM_ELEVATOR; j++) {
  131. int r = inputBuffer[(j*3)+1];
  132. int g = inputBuffer[(j*3)+2];
  133. int b = inputBuffer[(j*3)+3];
  134. int w = min (r, min(g, b));
  135. r = r- w;
  136. g = g - w;
  137. b = b - w;
  138. strip_elevator.setPixelColor(j, r, g, b, w);
  139. strip_elevator.show();
  140. }
  141. }
  142. if(inputBuffer[0] == 4){
  143. for (int j = 0; j < NUM_NFC+NUM_CHASE; j++) {
  144. int r = inputBuffer[(j*3)+1];
  145. int g = inputBuffer[(j*3)+2];
  146. int b = inputBuffer[(j*3)+3];
  147. int w = min (r, min(g, b));
  148. r = r- w;
  149. g = g - w;
  150. b = b - w;
  151. strip_chase.setPixelColor(j, r, g, b, w);
  152. strip_chase.show();
  153. }
  154. }
  155. if(inputBuffer[0] == 5){
  156. for (int j = 0; j < NUM_NFC+NUM_PATHWAY2; j++) {
  157. int r = inputBuffer[(j*3)+1];
  158. int g = inputBuffer[(j*3)+2];
  159. int b = inputBuffer[(j*3)+3];
  160. int w = min (r, min(g, b));
  161. r = r- w;
  162. g = g - w;
  163. b = b - w;
  164. strip_pathway2.setPixelColor(j, r, g, b, w);
  165. strip_pathway2.show();
  166. }
  167. }
  168. if(inputBuffer[0] == 6){
  169. for (int j = 0; j < NUM_NFC+NUM_COLORIZER; j++) {
  170. int r = inputBuffer[(j*3)+1];
  171. int g = inputBuffer[(j*3)+2];
  172. int b = inputBuffer[(j*3)+3];
  173. int w = min (r, min(g, b));
  174. r = r- w;
  175. g = g - w;
  176. b = b - w;
  177. strip_colorizer.setPixelColor(j, r, g, b, w);
  178. strip_colorizer.show();
  179. }
  180. }
  181. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement