当前位置:首页 > 科学研究 > 电子编程 > 正文内容

Arduino Project 011 - Piezo Sounder Alarm

RonWang4个月前 (07-30)电子编程68

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
   July 30th 2024
   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

版权声明:本文为原创文章,版权归donstudio所有,欢迎分享本文,转载请保留出处!

本文链接:http://www.donstudio.cn/?id=261

标签: Arduino

相关文章

Arduino Project 032 - BMP280 Pressure Sensor LCD Display

Arduino Project 032 - BMP280 Pressure Sensor LCD Display

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

C语言调试运行环境Pelles C的安装

C语言调试运行环境Pelles C的安装

C语言调试运行环境之TurboC一文介绍了在32位Windows系统下安装C语言运行环境之TubroC,但是由于TurobC只能在32位系统下运行,导致现在很多Windows10和Windows 11...

Arduino Project 005 - LED Chase Lights

Arduino Project 005 - LED Chase Lights

You’re going to use a string of LEDs (10 in total) to make an LED chase effect, similar to that used...

Arduino Project 023A - Liquid Crystal Displays - Autoscroll

Arduino Project 023A - Liquid Crystal Displays - Autoscroll

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

Arduino Programming Basic - Bollean

Arduino Programming Basic - Bollean

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

Arduino Programming Basic - Variables

Arduino Programming Basic - Variables

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

发表评论

访客

看不清,换一张

◎欢迎参与讨论,请在这里发表您的看法和观点。