Back to Parent

Acting

Based on a set of conditional statements, a countries flag colors are shown in sequence on the neopixel strip based on a list of colors specified in a predefined function for that country. If no country or nationality is recognized the neopixel cycles through the rainbow. It pulses and ultimately turns off while it checks the motion sensor. 

The flagColors function takes a list of unsigned 32-bit integers, which is the datatype for neopixel colors, and cycles through the colors of each pixel one by one in sequence. Because of the way the language handles unsigned 32-bit integers when compiled it does not allow for the size of the list to be recognized as more than 4. So, all color lists must have four color objects regardless of the actual amount of colors on the flag. This is why many of the countries functions use black (the color that sets of all pixels to off) as a terminating variable.

The function turnoff is flagColors with a list of only the color black. The function rainbow uses its own for loop hardcoded to use all 8 colors defined to eliminate the delay that would occur in the middle of the list. The function pulse is meant to provide a subtle breath which is initialized during the reaction checking process. It changes all the pixels simultaneously unlike whenever the flagColors, which shows each pixel with a slight delay between each light's change. 


Content Rating

Is this a good/useful/informative piece of content to include in the project? Have your say!

0