//This code is intended for the HTMAA 2023 Final Project of Shea Landeene: Flora Aura, a nature-inspired lamp that responds in inverse to the detected ambient light in an environment // Phototransistor reference code provided by https://thearduinoworkshop.weebly.com/photodiode.html // NeoPixel Jewel 7 refrence code provided by https://github.com/adafruit/Adafruit_NeoPixel // Code modified by Shea Landeene for HTMAA 2023 //define variables #include #define PIN 26 //output pin #define NUMPIXELS 7 //# pixels on NeoPixel Jewel 7 #define DELAYVAL 0 //delay time between individual NeoPixel illumination int sensorPin = A1; //input pin int sensorMax = 1023; //maximum value phototransistor will report based on light detection int boost = 6; //sensitivity parameter to adjust NeoPixel response to light in varying levels of ambient light Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); void setup(void) { Serial.begin(9600); pinMode(sensorPin, INPUT); pixels.begin(); } void loop(void) { float sensorPercent = ((float)analogRead(sensorPin)) / sensorMax; //normalize phototransistor sensor readings float sensorBoosted = 1.f-constrain(sensorPercent * boost, 0.f, 1.f); //boost the input reading by the sensitivity parameter, and gain percentage in relation to inverse of ambient light Serial.println(sensorBoosted); pixels.clear(); //update color values depending on desired illumination color of NeoPixel Jewel 7 int red_brightness = 200; int green_brightness = 120; int blue_brightness = 120; float red_percent = sensorBoosted; float green_percent = sensorBoosted; float blue_percent = sensorBoosted; //NeoPixel Jewel 7 response based on ambient light presence detected by phototransistor for(int i=0; i