This is what my code looks like right now. It works, in theory. It does what I told it to do and the brightness it responding to the proximity sensor reading. The new issue is the binary nature of this sketch. The transition from one state of brightness into the next state of brightness is too binary/cut and paste.. I would like it to "fade" better than it does so that the brightness transitions are smoother..
#include <FastLED.h>
#include <NewPing.h>
#define LED_PIN 7
#define NUM_LEDS 151
#define CHIPSET WS2813
#define COLOR_ORDER GRB
CRGB leds[NUM_LEDS];
#define TEMPERATURE_1 Tungsten100W
#define TEMPERATURE_2 OvercastSky
#define PING_PIN 12 // Arduino pin tied to both trigger and echo pins on the ultrasonic sensor.
#define MAX_DISTANCE 120 // Maximum distance we want to ping for (in centimeters). Maximum sensor dista
NewPing sonar(PING_PIN, PING_PIN, MAX_DISTANCE);
int proxcont = 0;
const int numReadings = 20 ;
int readings [ numReadings ] ;
int readIndex = 0;
int total = 0;
int average = 0;
int newValue = 0;
int lastpixel = 0;
// How many seconds to show each temperature before switching
#define DISPLAYTIME 20
// How many seconds to show black between switches
#define BLACKTIME 3
void setup() {
delay(1000); // power-up safety delay
Serial.begin(9600);
Serial.println("resetting");
LEDS.addLeds<WS2813,LED_PIN,RGB>(leds,NUM_LEDS).setCorrection(TypicalLEDStrip);
FastLED.setBrightness(proxcont);
for(int thisReading = 0 ; thisReading < numReadings ; thisReading++) {
readings [ thisReading ] = 0 ; }
}
void loop()
{
proxcont = sonar.ping_cm();
delay(30); // Wait 50ms between pings (about 20 pings/sec). 29ms should be the shortest delay between pings.
Serial.print("distance: ");
Serial.print(sonar.ping_cm()); // Send ping, get distance in cm and print result (0 = outside set distance range)
Serial.println("cm");
delay(35);
// draw a generic, no-name rainbow
static uint8_t starthue = 0;
fill_rainbow( leds + 0, NUM_LEDS - 5, --starthue, 20);
// Choose which 'color temperature' profile to enable.
uint8_t secs = (millis() / 1000) % (DISPLAYTIME * 2);
if( secs < DISPLAYTIME) {
FastLED.setTemperature( TEMPERATURE_1 ); // first temperature
leds[0] = TEMPERATURE_1; // show indicator pixel
} else {
FastLED.setTemperature( TEMPERATURE_2 ); // second temperature
leds[0] = TEMPERATURE_2; // show indicator pixel
}
FastLED.show();
FastLED.delay(8);
if(proxcont > 0 && proxcont <= 1) {
int a = 160;
FastLED.setBrightness(a);
delay(30);
}
if(proxcont > 2 && proxcont <= 3) {
int b = 155;
FastLED.setBrightness(b);
delay(30);
}
if(proxcont > 4 && proxcont <= 5) {
int c = 150;
FastLED.setBrightness(c);
delay(30);
}
if(proxcont > 6 && proxcont <= 7) {
int d = 145;
FastLED.setBrightness(d);
delay(30);
}
if(proxcont > 8 && proxcont <= 9) {
int e = 140;
FastLED.setBrightness(e);
delay(30);
}
if(proxcont > 10 && proxcont <= 11) {
int f = 135;
FastLED.setBrightness(f);
delay(30);
}
if(proxcont > 12 && proxcont <= 13) {
int g = 130;
FastLED.setBrightness(g);
delay(30);
}
if(proxcont > 14 && proxcont <= 15) {
int h = 125;
FastLED.setBrightness(h);
delay(30);
}
if(proxcont > 16 && proxcont <= 17) {
int i = 120;
FastLED.setBrightness(i);
delay(30);
}
if(proxcont > 18 && proxcont <= 19) {
int j = 115;
FastLED.setBrightness(j);
delay(30);
}
if(proxcont > 20 && proxcont <= 21) {
int k = 110;
FastLED.setBrightness(k);
delay(30);
}
if(proxcont > 22 && proxcont <= 23) {
int l = 105;
FastLED.setBrightness(l);
delay(30);
}
if(proxcont > 24 && proxcont <= 25) {
int m = 100;
FastLED.setBrightness(m);
delay(30);
}
if(proxcont > 26 && proxcont <= 27) {
int n = 95;
FastLED.setBrightness(n);
delay(30);
}
if(proxcont > 28 && proxcont <= 29) {
int o = 90;
FastLED.setBrightness(o);
delay(30);
}
if(proxcont > 30 && proxcont <= 31) {
int p = 85;
FastLED.setBrightness(p);
delay(30);
}
if(proxcont > 32 && proxcont <= 33) {
int q = 80;
FastLED.setBrightness(q);
delay(30);
}
if(proxcont > 34 && proxcont <= 35) {
int r = 75;
FastLED.setBrightness(r);
delay(30);
}
if(proxcont > 36 && proxcont <= 37) {
int s = 70;
FastLED.setBrightness(s);
delay(30);
}
if(proxcont > 38 && proxcont <= 39) {
int t = 65;
FastLED.setBrightness(t);
delay(30);
}
if(proxcont > 40 && proxcont <= 41) {
int u = 60;
FastLED.setBrightness(u);
delay(30);
}
}