The object of this project is a flashlight created from cut cardboard and an Adafruit Circuit Playground Express connected to a switch and a potentiometer with alligator clips, powered by a battery. Flipping the switch turns the lights on or off. Twisting the knob on the potentiometer changes the colors at a low degree- then changes to a much brighter white light after turning the knob far enough.
The code itself was rather simple. On Start the A1 pin ( the switch) was set to up, and the A2 pin (the potentiometer) was set to down. Nested under the Forever loop was an If/Else logic brick. If A2 was read, then another If/Else brick was activated: If A1 is read, then the value of the potentiometer was graphed and the lights would change accordingly within a certain value range. Once the end value was reached, the lights would change to white. If neither of the pins were active (if the switch was shut off) then the lights would clear, and the flashlight was effectively off. Code was built and expanded upon the Make It Switch and Make it Change tutorials on Adafruit's website.














Comments