Guest User

Untitled

a guest
Dec 16th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.66 KB | None | 0 0
  1. #include <Wire.h>
  2.  
  3. #include <Adafruit_NeoPixel.h>
  4.  
  5. #include <SparkFun_GridEYE_Arduino_Library.h>
  6.  
  7. int pixTable[64];
  8.  
  9. GridEYE sensor;
  10.  
  11. #define NUM_LEDS 64
  12. #define LED_PIN 6
  13.  
  14. #define HOT 33
  15. #define COLD 20
  16.  
  17. int toggle = 4;
  18. int toggleVal = 0;
  19.  
  20. int GPOT = A3;
  21. int RPOT = A1;
  22. int BPOT = A2;
  23.  
  24. int coldG = 0;
  25. int coldR = 0;
  26. int coldB = 0;
  27.  
  28. int hotG = 0;
  29. int hotR = 0;
  30. int hotB = 0;
  31.  
  32. Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, LED_PIN, NEO_GRB + NEO_KHZ800);
  33.  
  34. void setup() {
  35.  
  36. Serial.begin(115200);
  37. Wire.begin();
  38. sensor.begin();
  39.  
  40. strip.begin();
  41. strip.show();
  42.  
  43. pinMode(toggle,INPUT);
  44.  
  45. }
  46.  
  47. void loop() {
  48.  
  49. //toggleVal = 0;
  50. toggleVal = digitalRead(toggle);
  51.  
  52. Serial.print(toggleVal);
  53. Serial.print(" ");
  54. Serial.print("G: ");
  55. Serial.print(coldG);
  56. Serial.print(" ");
  57. Serial.print("R: ");
  58. Serial.print(coldR);
  59. Serial.print(" ");
  60. Serial.print("B: ");
  61. Serial.print(coldB);
  62. Serial.print(" ");
  63. Serial.print("G: ");
  64. Serial.print(hotG);
  65. Serial.print(" ");
  66. Serial.print("R: ");
  67. Serial.print(hotR);
  68. Serial.print(" ");
  69. Serial.print("B: ");
  70. Serial.println(hotB);
  71.  
  72. // int cG = map(analogRead(A0),0,1023,0,255);
  73. // int cR = map(analogRead(A1),0,1023,0,255);
  74. // int cB = map(analogRead(A2),0,1023,0,255);
  75. //
  76. // int hG = map(analogRead(A0),0,1023,0,255);
  77. // int hR = map(analogRead(A1),0,1023,0,255);
  78. // int hB = map(analogRead(A2),0,1023,0,255);
  79.  
  80. if (toggleVal == HIGH)
  81. {
  82. coldG = map(analogRead(A3),0,1023,0,255);
  83. coldR = map(analogRead(A1),0,1023,0,255);
  84. coldB = map(analogRead(A2),0,1023,0,255);
  85. }
  86.  
  87. else if (toggleVal == LOW)
  88. {
  89. hotG = map(analogRead(A3),0,1023,0,255);
  90. hotR = map(analogRead(A1),0,1023,0,255);
  91. hotB = map(analogRead(A2),0,1023,0,255);
  92. }
  93.  
  94.  
  95.  
  96. for (int i=0; i<64; i++)
  97. {
  98. pixTable[i] = map(sensor.getPixelTemperature(i),COLD,HOT,0,3);
  99. }
  100.  
  101. for (int i=0; i<64; i++)
  102. {
  103. if (pixTable[i]==0)
  104. {
  105. //Serial.print(".");
  106.  
  107. //strip.setPixelColor(i,0,0,3);
  108. strip.setPixelColor(i,coldG/7,coldR/7,coldB/7);
  109. strip.show();
  110. }
  111.  
  112. else if (pixTable[i]==1)
  113. {
  114. //Serial.print("o");
  115.  
  116. // strip.setPixelColor(i,2,9,0);
  117. strip.setPixelColor(i,hotG/7,hotR/7,hotB/7);
  118. strip.show();
  119. }
  120.  
  121. else if (pixTable[i]==2)
  122. {
  123. //Serial.print("0");
  124.  
  125. //strip.setPixelColor(i,25,35,0);
  126. strip.setPixelColor(i,hotG/4,hotR/4,hotB/4);
  127. strip.show();
  128. }
  129.  
  130. else if (pixTable[i]==3)
  131. {
  132. //Serial.print("O");
  133.  
  134. //strip.setPixelColor(i,30,40,0);
  135. strip.setPixelColor(i,hotG,hotR,hotB);
  136. strip.show();
  137. }
  138.  
  139. //Serial.print(" ");
  140.  
  141. if((i+1)%8==0)
  142. {
  143. // Serial.println();
  144. }
  145. }
  146.  
  147. //Serial.println();
  148. //Serial.println();
  149.  
  150. }
Add Comment
Please, Sign In to add comment