Lights Neopixels and NeoTrellis - Final Project Step 4

Our first step with the lights was to change the potentiometers to show H, S, V instead of R, G, B and Brightness. We were able to switch this around by using this in our Arduino code:

for (int i = 0; i <= 11; i++){

//uint32_t rgbcolor = strip.ColorHSV(mappedPotH, mappedPotS, mappedPotV);

uint32_t rgbcolor = strip.gamma32(strip.ColorHSV(mappedPotH, mappedPotS, mappedPotV));

strip.fill(rgbcolor);

}

We then wanted to be able to issolate one half of the NeoPixel array at a time and then change the HSV for that selected portion. We add a button to our breadboard and updated the code and were about to do it!

IMG_0975.JPG

arduino code:

#include <Adafruit_NeoPixel.h>

#ifdef __AVR__

#include <avr/power.h>

#endif

#define LED_PIN 6

#define LED_COUNT 11

Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);

void setup() {

  pinMode(2, INPUT);

#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)

    clock_prescale_set(clock_div_1);

#endif

  strip.begin();

  // strip.show();

}

void loop() {

  int potentiometerH = analogRead(A2);

  int potentiometerS = analogRead(A3);

  int potentiometerV = analogRead(A4);

  int button = digitalRead(2);

  int mappedPotH = map(potentiometerH, 0, 1023, 0, 65536);

  int mappedPotS = map(potentiometerS, 0, 1023, 0, 255);

  int mappedPotV = map(potentiometerV, 0, 1023, 0, 255);

Serial.print(mappedPotH);

  Serial.print(",");

  Serial.print(mappedPotS);

  Serial.print(",");

  Serial.print(mappedPotV);

  Serial.print(",");

  Serial.println(button);

//delay(1);

  if (digitalRead(2) == HIGH) {

    for (int i = 0; i <= 5; i++) {

      uint32_t rgbcolor = strip.gamma32(strip.ColorHSV(mappedPotH, mappedPotS, mappedPotV));

      strip.setPixelColor(i, rgbcolor);

      strip.show();

      for (int i = 6; i <= 10; i++) {

        uint32_t rgbcolor = strip.gamma32(strip.ColorHSV(0, 0, 0));

        strip.setPixelColor(i, rgbcolor);

        strip.show();

      }

    }

} else {

    for (int i = 0; i <= 5; i++) {

      uint32_t rgbcolor = strip.gamma32(strip.ColorHSV(0, 0, 0));

      strip.setPixelColor(i, rgbcolor);

      strip.show();

    }

for (int i = 6; i <= 10; i++) {

      uint32_t rgbcolor = strip.gamma32(strip.ColorHSV(mappedPotH, mappedPotS, mappedPotV));

      strip.setPixelColor(i, rgbcolor);

      strip.show();

    }

  }

}

//  if (digitalRead(2) == HIGH) {

//    for (int i = 0; i <= 5; i++) {

//      uint32_t rgbcolor = strip.gamma32(strip.ColorHSV(mappedPotH, mappedPotS, mappedPotV));

//      strip.setPixelColor(i, rgbcolor);

//      strip.show();

//      //save values and hold until HIGH again

//    }

//

//

//  } else {

//    for (int i = 0; i <= 5; i++) {

//      uint32_t rgbcolor = strip.gamma32(strip.ColorHSV(40000, 100, 100));

//      strip.setPixelColor(i, rgbcolor);

//      strip.show();

//    }

//  }

//}

Previous
Previous

Playtesting Part 2 - Final Project Step 5

Next
Next

Playtesting - Final Project Step 3