CODE | Piezo Sounder Alarm - Arduino Project 011

RonWang3 years ago (2023-08-07)电子编程 COD18

Arduino project - sounder and sensors : Include project 11 Piezo Sounder Alarm ,Project piezo sounder Melody player , Project 13 Piezo knock sensor and Project 14 Light sensor.

电子编程--声音和传感器项目,主要包含以下几个项目,项目11 压电声音报警器,项目12 压电扬声器音乐演奏,项目13压电振动传感器,项目14光敏传感器。

By connecting a piezo sounder to a digital output pin, you can create a wailing alarm sound. It’s the same principle that you used in Project 7 when creating a pulsating lamp via a sine wave, but this time you replace the LED with a piezo sounder or piezo disc. 

项目 Project 11 – Piezo Sounder Alarm

/* Coding Ron Wang
   Aug 7th 2023
   Autaba support for coding hardware
 */
// Project 11 - Piezo Sounder Alarm
float sinVal;
int toneVal;
void setup() {
 pinMode(8, OUTPUT);
}
void loop() {
 for (int x=0; x<180; x++) {
 // convert degrees to radians then obtain sin value
 sinVal = (sin(x*(3.1412/180)));
 // generate a frequency from the sin value
 toneVal = 2000+(int(sinVal*1000));
 tone(8, toneVal);
 delay(2);
 }
}

arduino Piezo Sounder Alarm Circuit

 Piezo Sounder Alarm Schematic

Share with Friends:

Related Articles

CODE | LED Interactive Traffic Lights - Arduino Project 004

CODE | LED Interactive Traffic Lights - Arduino Project 004

This time you are going to extend the previous project to include a set of pedestrian lights and a p…

Series and parallel circuits

Series and parallel circuits

Two-terminal components and electrical networks can be connected in series or parallel. The resultin…

Resistor-Electrical Components

Resistor-Electrical Components

A resistor is a passive two-terminal electrical component that implements electrical resistance as a…

CODE | Liquid Crystal Displays-Custom Character - Arduino Project 023D

CODE | Liquid Crystal Displays-Custom Character - Arduino Project 023D

Before wiring the LCD screen to your Arduino board we suggest to solder a pin header strip to the 14…

CODE | Control Stepper Motor ULN2004A - Arduino Project 029

CODE | Control Stepper Motor ULN2004A - Arduino Project 029

Stepper motors, due to their unique design, can be controlled to a high degree of accuracy without a…

CODE | Input and Output- Arduino Programming Basic

CODE | Input and Output- Arduino Programming Basic

The pins on the Arduino can be configured as either inputs or outputs. This document explains the fu…

Post a Comment

Anonymous

Feel free to share your thoughts and opinions here.