The NeoPixel leds on the Circuit Playground Express are too great not to be used in my opinion so I decided to integrate them into the instrument giving the player super cool performance lighting.

I chose a rainbow ordered color scheme and decided to set the brightness of the leds based on the loudness of the note.

In my code I have a different color that is shown for each pitch.

  • To set or change the color of the leds, go to the light tab and grab a "set all pixels to" element.
  • Now drag it up to the button A if statement and inside of the first inner if else, under the lowest note.
  • Now choose your desired color.
  • Copy, paste and repeat until all pitches on buttons A and B have colors assigned.
Button A colors assigned.
Make sure you do choose colors for button B as well.

To set the brightness let's utilize the last if statement we wrote to control volume. We can set lighting levels where we set sound levels so they match.

  • Go to the light tab, grab a set brightness element and place it under the first set volume element in the volume if statement.
  • Set the brightness to 220.
  • Repeat for all volume levels.

One last thing we need to take care of before finishing up with the code is making sure the NeoPixels turn off if neither button is bring pressed.

  • To ensure this happens, we place a "set all NeoPixels" element in the outside "else" part of the pitch if statement.
  • Change the color to black.

All done with code!


Here's the full project you can play with from MakeCode's platform.

This guide was first published on Apr 11, 2018. It was last updated on Mar 08, 2024.

This page (Adding NeoPixel Awesomeness) was last updated on Mar 08, 2024.

Text editor powered by tinymce.