I used Microsoft MakeCode to make the program for the board. I used the Adafruit switch and potentiometer tutorials. It is an imaginary alien instrument that is controlled by a switch and a potentiometer/knob. The switch turns the instrument on and off. The potentiometer changes the tone the circuit board is making. It plays at a consistent speed and a duration of ⅛ of a second. It is encased in a cardboard box. The switch and knob are come out the front and are on opposite sides of the box and circuit board. A lithium battery powers it.
The code sets pin A2 to look for the switch in on start. It starts as being set to up. It also sets the volume to 128 which is a medium volume the board can do. It then moves on to the forever loop. It contains an if-else statement. If it does not read the digital pin A2 as receiving voltage then it sets a variable named value to whatever it reads the Analog data from pin A6 as. The potentiometer is connected to A6 so it gets input from the potentiometer. It then uses the value placed in the value variable to tell the board what tone to play at. It also tells the board to play the sound for ⅛ of a second. If the switch s flipped back then all sound is stopped as if the instrument was turned off.
Comments
Please log in or sign up to comment.