Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#include <Adafruit_NeoPixel.h> #ifdef __AVR__ #include <avr/power.h> #endif #define PIN 3 #define NUMPIXELS 144 int uvvalue; /* int green[3]={0,255,0}; int yello[3]={255,255,0}; int orenge[3]={255,127,39}; int red[3]={255,0,0}; int puple[3]={163,73,163}; */ int colorValue[5][3]={0,255,0 ,255,255,0 ,255,127,39 ,255,0,0 ,163,73,163}; Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); int delayval = 500; // delay for half a second void setup() { #if defined (__AVR_ATtiny85__) if (F_CPU == 16000000) clock_prescale_set(clock_div_1); #endif pinMode(A0,INPUT); //pixels.setBrightness(5); pixels.begin(); // This initializes the NeoPixel library. Serial.begin(9600); } void loop() { // For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pixels minus one. uvvalue=analogRead(A0); Serial.print(uvvalue); if(uvvalue<3) { uvvalue=0; } else if(uvvalue<6) { uvvalue=1; } else if(uvvalue<8) { uvvalue=2; } else if(uvvalue<11) { uvvalue=3; } else { uvvalue=4; } Serial.print(" "); Serial.print(colorValue[uvvalue][0]); Serial.print(" "); Serial.print(colorValue[uvvalue][1]); Serial.print(" "); Serial.println(colorValue[uvvalue][2]); for(int i=0;i<NUMPIXELS;i++){ pixels.setPixelColor(i, pixels.Color(colorValue[uvvalue][0],colorValue[uvvalue][1],colorValue[uvvalue][2])); pixels.show(); // This sends the updated pixel color to the hardware. } }
- Loading branch information