• We must next create a counter that will track button presses. This counter will let the program know which note should be sounded when blown as well as which NeoPixel and color should be on.
  • We declare the counter outside of the following while loop so that it doesn’t get reset back to 0 at the beginning of each loop.
#Create a counter for tracking button presses
#Declared outside scope of while loop so it doesn't get reset to 0 at the beginnning of every loop!
counter = 0

This guide was first published on Mar 28, 2018. It was last updated on Mar 28, 2018.

This page (Tracking Button Presses with a Counter) was last updated on Mar 26, 2018.

Text editor powered by tinymce.