Skip to content

Commit

Permalink
Create UV monitoring
Browse files Browse the repository at this point in the history
#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
HyunseungLee-CRC committed Dec 12, 2020
1 parent 9e03252 commit e46b26c
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions UV monitoring
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

0 comments on commit e46b26c

Please sign in to comment.