Close

RGB light strips, essential

A project log for Tyhac covid-19 audio diagnostic stack

Tyhac is a multi-mode device made possible by deep learning and AWS. The stack stores and predicts covid-19 audio cough samples in realtime.

mickmick 10/24/2021 at 09:390 Comments

I did a bit of a side step to have some fun with the device after the AWS S3 upload saga which was a bit of nightmare. The AWS EduKit comes with RGB light strips either side of the device which I think would be good status indicators. 

Fastled

Looking at the M5 examples, a popular Arduino library fastled appears to be a good fit and is pretty simple to use, a simple example from the fastled repo:

void loop() {
   // Move a single white led 
   for(int whiteLed = 0; whiteLed < NUM_LEDS; whiteLed = whiteLed + 1) {
      // Turn our current led on to white, then show the leds
      leds[whiteLed] = CRGB::White;

      // Show the leds (only one of which is set to white, from above)
      FastLED.show();

      // Wait a little bit
      delay(100);

      // Turn our current led back to black for the next loop around
      leds[whiteLed] = CRGB::Black;
   }
}

This looks easy enough, if we look further there is a neat little enum with a bunch of common colors that should make it easy to use and it is...but, there appears to be an issue with the RGB order in the M5. This means, I know I need to pick RGB colors and it's best to split the code out further, github bug.

The cool thing is that each led is set one after the other, setting a delay can add a pretty cool effect that shows almost like a loading lights which you can again loop. I've done this for the bootup and other sequences.

Green Blue Red

The order is actually green, blue, red for the M5, a simple change to the order is all that is needed:

void setRgbColor(uint8_t green, uint8_t blue, uint8_t red)
{
    for (int i = 0; i < LEDS_NUM; i++)
    {
        ledsBuff[i] = ledsBuff[i].setRGB(green, red, blue);
        FastLED.show();
        delay(100);
        FastLED.setBrightness(100); // turn down the brightness, blinding at night
    }
}

RGB lights

Here are the lights working showing the white lights which I've configured to be sleeping / idle mode lights:


Discussions