Learning Outcome
In this chapter, we learn to
program EDU PICO to read analog values from potentiometer.
measure noise in dB with the PDM sound sensor.
Introduction: Potentiometer and PDM Sound Sensor.
Activities: Build a noise pollution monitoring system (Room Environment Noise Indicator)
Challenge: Program a servo motor to serve as a sound level meter.
Introduction to Potentiometer
In this lesson, you will learn to interpret analog signal voltage while manipulating a variable resistor or a potentiometer (pot). This is also one of the more popular projects created for beginners to learn how to control electrical output by using a simple analog input device.
> Libraries <
-> Libraries: board, time, AnalogIn.
-> Potentiometer Configuration: GP28 with analog input.
-> Input:
Turning the potentiometer knob will alter the output flow of electricity.
Turning the knob clockwise will increase the voltage, and anti-clockwise will reduce the voltage.
< Expected Output >
Upon completion the activity, you should be able to:
-> Continuously reads the voltage from analog pin GP28 (connected to the EDU PICO potentiometer).
-> Display the voltage value to the shell console at an interval of 0.1 second.
Introduction to PDM Microphone
A PDM microphone, or Pulse-Density Modulation microphone, is a type of microphone that converts sound waves into a digital signal. Unlike our traditional microphones that use analog signal, the digital signals produced by PDM microphones are more resistant to noisy environment, making them ideal for applications such as smart home voice commands, noise level monitoring, or even sound analysis.
> Libraries <
-> Libraries: board, time, array, math, audiobusio
-> PDM microphone configuration: Data (DAT) = GP2, Clock (CLK) = GP3.
< Expected Output >
Upon completion of the activity, you should be able to:
-> The sensor will measure sound level in voltage (magnitude) and convert it to sound level in decibels (dB).
-> If the magnitude is greater than 0, the code prints the sound level in decibels (dB) at the shell console with an interval of 0.1 second.
-> If the magnitude is less than 0, the code prints "Magnitude is too small to calculate dB" at the shell console.
Noise Pollution Monitoring System
Noise pollution is a critical issue that often goes unnoticed in our ever-expanding urban society, ultimately affecting our overall well-being and quality of life. Fortunately, we can address this problem with the help PDM microphone and EDU PICO. By learning how to use these tools, we can effectively measure and analyze the noise levels in our environment. Through this section, we will program a fully functional noise monitoring system that allows users to input an acceptable noise limit. In no time, you'll be able to deploy your EDU PICO for accurate noise measurement in your classroom or local library!
> Libraries <
-> Libraries: board, time, AnalogIn, neopixel, busio, array, audiobusio, math, adafruit_ssd1306.
-> PDM Microphone Configuration: GP2 and GP3.
-> OLED I2C Configuration: SCL = GP5 and SDA = GP4.
-> Potentiometer Configuration: GP28 with analog input.
-> Input:
Ambient noise (The louder the noise, the higher the decibel (dB)).
Adjust potentiometer value to adjust noise threshold.
< Expected Output >
Upon completion of the activity, you should be able to:
-> If noise received from PDM microphone exceeds the threshold value set by the potentiometer, the RGB LEDs will light up in red, indicating the space is too noisy.
-> If noise is below the threshold, RGB LEDs will light up in green, indicating a safe noise level.
Challenges
#1 - Servo Sound Meter
Having an OLED to display noise decibels is great; however, in practical usage, the OLED may be too small fir everyone in the surroundings to notice. In this challenge, we will solve this problem by integrating a servo motor as a noise indicator, reflecting the values displayed on the OLED, but in a physical form with a larger view.
> Libraries <
-> Libraries: board, time, neopixel, busio, array, math, audiobusio, adafruit_ssd1306.
-> PDM Microphone Configuration: GP2 and GP3.
-> OLED I2C Configuration: SCL = GP5 and SDA = GP4.
-> Potentiometer Configuration: GP28 with analog input.
< Expected Output >
Upon completion of the activity, you should be able to:
-> The program will initialize the servo motor pin and perform a servo test by sweeping the motor through its range from 0 to 180 degrees.
-> Calculate and check the angle based on sound level in decibels (dB) to make sure it's within 0 to 180 degrees before rotating the servo motor.
Great Work Completing Chapter 6! Let's Explore the Next Chapter