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

Arduino Project 011 - Piezo Sounder Alarm

RonWang9个月前 (07-30)电子编程208

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 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...

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

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

上大学时学习《C语言程序设计》(第二版)作者谭浩强,大部分编程时间是在学校机房度过,每次点开桌面的TurboC图标,就开始在里面敲代码,然后保存程序Abc.C,下一步进行编译,如果编译成功的话,就可以...

Arduino Project 019 - LED Dot Matrix Display - Basic Animation

Arduino Project 019 - LED Dot Matrix Display - Basic Animation

So far you have dealt with individual 5mm LEDs. LEDs can also be obtained in a package known as a do...

Arduino Programming Basic - Serial Monitor

Arduino Programming Basic - Serial Monitor

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

 ​Arduino Project 049 - IR Remote Control

​Arduino Project 049 - IR Remote Control

Project 49 IR Remote Control/* Project 49 IR Remote Control  * C...

Arduino Project 025 - Servo Control

Arduino Project 025 - Servo Control

You will need to obtain a standard RC servo; any of the small or mid-sized servos will do. Larger se...