b'Circuit 2A: Buzzer In this circuit, youll use the RedBoard and a small buzzer to make music, and youll learn how to program your own songs using arrays.YOUPOTENTIOMETERPIEZO BUZZER4 JUMPER WIRES NEEDNEW COMPONENTS frequency on the specified pin. The frequency and duration can both be passed BUZZER: The buzzer uses a smallto the tone() function when calling it. magnetic coil to vibrate a metal disc insideTo turn the tone off, you need to call a plastic housing. By pulsing electricitynoTone() or pass a duration of time for it through the coil at different rates, differentto play and then stop. Unlike PWM, tone() frequencies (pitches) of sound can becan be used on any digital pin.produced. Attaching a potentiometer to the output allows you to limitARRAYS are used like variables, but they the amount of current movingcan store multiple values. The simplest through the buzzer and lowerarray is just a list. Imagine that you want its volume. to store the frequency for each note of the C major scale. We could make seven NEW CONCEPTS variables and assign a frequency to each one, or we could use an array and RESET BUTTON: The RedBoard has astore all seven in the same list. To refer built-in reset button. This button will resetto a specific value in the array, an index the board and start the code over from thenumber is used. Arrays are indexed from beginning, running setup()then loop().0. For example, to call the first element in the array, use array_name[0]; to call the second element, use array_name[1]; and SDA AREF GND 13 12 ~11 ~10 ~9 8 7 ~6 ~5 4 ~3 2 1 TX 0 RXSCLDIGITAL (PWM ~)13 so on.TXRX ONO YC N E U HC106 START SOMETHINGLA C I T ZC106 I/O ISP E ) USINGUSING AN 3.3V 5V S U N Q ( VARIABLES ARRAYC106 M E R FIOREF RESET 3.3V 5V GND POWER GND VIN A0 A1 ANALOG IN A2 A3 A4 A5A 220 A_FREQUENCY FREQUENCY[0]B 247 B_FREQUENCY FREQUENCY[1]C 261 C_FREQUENCY FREQUENCY[2]TONE FUNCTION: To control theD 294 D_FREQUENCY FREQUENCY[3]buzzer, you will use the tone() function.E 330 E_FREQUENCY FREQUENCY[4]This function is similar to PWM in thatF 349 F_FREQUENCY FREQUENCY[5]G 392 G_FREQUENCY FREQUENCY[6]it generates a wave that is of a certain 37 : circuit 2a'