CODE | Piezo Sounder Alarm - Arduino Project 011

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

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 | Ultrasonic Distance OLED 128x64 Display - Arduino Project 041

CODE | Ultrasonic Distance OLED 128x64 Display - Arduino Project 041

About the Ultrasonic sensor knowledge and infor mation click the link : Arduino Project 038 - S…

CODE | BMP280 Pressure Sensor LCD Display - Arduino Project 032

CODE | BMP280 Pressure Sensor LCD Display - Arduino Project 032

For this project we will use Arduino Uno and BMP280 along with LCD 16x2 display module to display te…

CODE | LED SOS Morse Code Singal - Arduino Project 002

CODE | LED SOS Morse Code Singal - Arduino Project 002

Arduino 电子编程--灯项目及控制,主要使用Arduino编程控制LED灯,实现基本控制Project 2 LED闪烁S.O.S信号。Project 2 S.O.S Morse Sig…

CODE | Variables - Arduino Programming Basic

CODE | Variables - Arduino Programming Basic

Arduino 程序基础,介绍Arduino程序的基本组成,第一部分编写了10个例子,关于变量及变量名称,串口监视器,if循环,for循环,while循环等。第二部分介绍了函数,全局变量,局部变量和静…

CODE | LED Fire Effect - Arduino Project 009

CODE | LED Fire Effect - Arduino Project 009

Project 9 will use LEDs and a flickering random light effect, via PWM again, to mimic the effect of…

CODE | Dual Servo Control - Arduino Project 026

CODE | Dual Servo Control - Arduino Project 026

This project you’ll create another simple project, but this time you’ll control two servos using com…

Post a Comment

Anonymous

Feel free to share your thoughts and opinions here.