Page 232 - ARM Based Microcontroller Projects Using MBED
P. 232
218 8. INTERMEDIATE LEVEL PROJECTS
/*************************************************************************
FLASHING LED WITH POTENTIOMETER
===============================
In this project the arm of s potentiometer is connected to analog input
PA_0 of teh Nucleo-F411RE development board. The User LED on the board
is flashed where the flashing rate is controlled by the potentiometer as
the potentiometer arm is rotated. The flashing rate is 0 (no flashing)
to flashing every second
Author: Dogan Ibrahim
Date : August 2018
File : POTLED
**************************************************************************/
#include "mbed.h"
Serial MyPC(USBTX, USBRX);
AnalogIn pot(PA_0);
DigitalOut MyLED(LED1);
#define ON 1
#define OFF 0
int main()
{
float Dig;
while(1) // Do forever
{
Dig = pot.read(); // In mV
MyLED = ON; // LED ON
wait(Dig); // Delay
MyLED = OFF; // LED OFF
wait(Dig); // Delay
}
}
FIG. 8.88 Program listing.
8.26 PROJECT 22—SOUND LEVEL METER
8.26.1 Description
This is a sound level project. A small electret microphone-based preamplifier module is
connected to analog input PA_0 of the Nucleo-F411RE development board. The project mea-
sures the peak-to-peak voltage output of the amplifier and displays this voltage on the PC
screen in millivolts. This voltage is proportional to the ambient sound level (in dB) and should
be calibrated for accuracy using a professional sound level meter.
8.26.2 Aim
The aim of this project is to show how a sound level meter can be designed.