
“There’s Always Sunshine” is a LED light made with a UV Light Sensor. It’s for people who’s experiencing seasonal depression to remind themselves that there can always be sunshine and stay positive. The light will work as when the sun goes down / when it’s cloudy or rainy, it lights up. You can toggle a button for the light to fade, otherwise the light stays on.
Instructables
https://www.instructables.com/Theres-Always-Sunshine-Light/
Video – It Works!
Process Photos














Tinkercad

Code
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
#define BUTTON_PIN 2
#define WHITELIGHT_PIN 5
#define PIXEL_PIN 6
#define UV_PIN A5
#define PIXEL_COUNT 7
Adafruit_NeoPixel strip(PIXEL_COUNT, PIXEL_PIN, NEO_GRB + NEO_KHZ800);
int buttonState = 0;
int lastButtonState = 0;
int buttonPushCounter = 0;
int sensorValue = 0;
//int brightnessWL = 0;
int fadeamount = 5;
bool isFading;
//SETUP
void setup() {
pinMode(BUTTON_PIN, INPUT_PULLUP);
//pinMode(UV_PIN, INPUT);
pinMode(WHITELIGHT_PIN, OUTPUT);
//pinMode(PIXEL_PIN,OUTPUT);
strip.begin();
strip.show();
Serial.begin(9600);
}
void loop() {
//check sensor value
sensorValue = analogRead(UV_PIN);
Serial.print("sensorValue= ");
Serial.print(sensorValue);
buttonState = digitalRead(BUTTON_PIN);
Serial.print("\t buttonState= ");
Serial.println(buttonState);
if (buttonState == LOW) {
isFading = true;
Serial.println("isFading is true");
}else {
isFading = false;
Serial.println("isFading is false");
}
if (sensorValue <= 2) {
Serial.println("sensor smaller than or equal to 2, lights on");
colorWipe(strip.Color(255, 70, 10), 5);
if(isFading == true){
// fade in from min to max in increments of 5 points:
for (int brightnessWL = 255; brightnessWL >= 50; brightnessWL -= 5) {
Serial.print("brightness= ");
Serial.println(brightnessWL);
analogWrite(WHITELIGHT_PIN, brightnessWL);
// wait for 30 milliseconds to see the dimming effect
delay(50);
}
for (int brightnessWL = 50; brightnessWL <= 255; brightnessWL += 5) {
Serial.print("brightness= ");
Serial.println(brightnessWL);
analogWrite(WHITELIGHT_PIN, brightnessWL);
delay(50);
}
// fade out from max to min in increments of 5 points:
} else {
digitalWrite(WHITELIGHT_PIN, 255);
}
}
else if (sensorValue > 2) {
Serial.println("sensor greater than 2, lights out");
digitalWrite(WHITELIGHT_PIN, LOW);
colorWipe(strip.Color(0, 0, 0), 5);
}
// save the current state as the last state, for
// the next time through the loop
lastButtonState = buttonState;
}
//SET PIXEL FUCTION
void colorWipe(uint32_t color, int wait) {
for(int i=0; i<strip.numPixels(); i++) { // For each pixel in strip...
strip.setPixelColor(i, color); // Set pixel's color (in RAM)
strip.show(); // Update strip to match
delay(wait); // Pause for a moment
}
}





























































