Adafruit Flora Color Sensor

This is a special forum devoted to educators using Adafruit and Arduino products for teaching.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
AngelicaSandoval
 
Posts: 3
Joined: Wed Apr 27, 2022 4:06 pm

Adafruit Flora Color Sensor

Post by AngelicaSandoval »

Hello-

I have purchased a couple of flora color sensors and Neo pixels to try out the Chameleon Scarf project. I would like to demonstrate the project to my class. Is there a way to make the color change continuous instead of having to reset the micro controller? I read on one of the topics that the Piano glove sketch calls out a continuous color change. I am very new to using the products and coding, would I be able to use the coding from the Chameleon scarf project but revise it to be a continuous color change? If so, what would that code be?

User avatar
dastels
 
Posts: 15656
Joined: Tue Oct 20, 2015 3:22 pm

Re: Adafruit Flora Color Sensor

Post by dastels »

I would start by moving the last part of setup() starting with uint16_t clear, red, green, blue; to loop()

I'm not sure that will have the desired behaviour though. You might want to add a button and execute that code only when the button is pressed.

Dave

User avatar
AngelicaSandoval
 
Posts: 3
Joined: Wed Apr 27, 2022 4:06 pm

Re: Adafruit Flora Color Sensor

Post by AngelicaSandoval »

Thank you.

I would like for the color changing to be continuous similar to the piano glove project except without the added sound. Ideally the on/off button would be hidden as the neo pixels change in color.

User avatar
AngelicaSandoval
 
Posts: 3
Joined: Wed Apr 27, 2022 4:06 pm

Re: Adafruit Flora Color Sensor

Post by AngelicaSandoval »

I kept getting an error on the sketch. "function definition is not allowed before '{' token. Not sure what I am missing since I am beginner.

Code: Select all

void loop() {
  uint16_t clear, red, green, blue;
  tcs.setInterrupt(false);      // turn on LED
  delay(60);  // takes 50ms to read 
    tcs.getRawData(&red, &green, &blue, &clear);
  tcs.setInterrupt(true);  // turn off LED
}
Attachments

[The extension ino has been deactivated and can no longer be displayed.]

Last edited by dastels on Thu Apr 28, 2022 10:57 am, edited 1 time in total.
Reason: Code block

User avatar
dastels
 
Posts: 15656
Joined: Tue Oct 20, 2015 3:22 pm

Re: Adafruit Flora Color Sensor

Post by dastels »

You are missing a closing brace at the end of the colorWipe function. The result is that the compiler is still inside the colorWipe function when it encounters the definition of the loop function and gets confused.

Code: Select all

void colorWipe(uint32_t c, uint8_t wait) {
  for(uint16_t i=0; i<strip.numPixels(); i++) {
      strip.setPixelColor(i, c);
      strip.show();
      delay(wait);
  }
}  // <---- THIS IS THE CLOSING BRACE THAT WAS MISSING

void loop() {
  uint16_t clear, red, green, blue;
Dave

Locked
Please be positive and constructive with your questions and comments.

Return to “For Educators”