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

Arduino Project 011 - Piezo Sounder Alarm

RonWang8个月前 (07-30)电子编程168

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://parentscn.com/?id=261

标签: Arduino

相关文章

Arduino Project 001 - LED Blink

Arduino Project 001 - LED Blink

Arduino 电子编程--灯项目及控制,主要使用Arduino编程控制LED灯,实现基本控制Project 1 LED闪烁,基本的应用Project 3和4红绿灯项目项目1 Project...

 Arduino Project 033 - 4 Digital 7 Segment Display

Arduino Project 033 - 4 Digital 7 Segment Display

Showing Heep and number 0-9 on a Common Anode 7-segment LED display. Displays the numbers 0-9 on the...

Arduino Project 015 - Simple Motor Control

Arduino Project 015 - Simple Motor Control

First, you’re going to simply control the speed of a DC motor in one direction, using a power transi...

Arduino Programming Basic - If and Loop

Arduino Programming Basic - If and Loop

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

Arduino Project 030A - Dual Motor Driver L298N

Arduino Project 030A - Dual Motor Driver L298N

L298N Dual Motor Driver Project Description  The L298N Motor Driver is a control...

Arduino Project 023B - Liquid Crystal Displays -Blink and Cursor

Arduino Project 023B - Liquid Crystal Displays -Blink and Cursor

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