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

Arduino Project 011 - Piezo Sounder Alarm

RonWang5个月前 (07-30)电子编程86

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 034 - TM1637 4Digital 7Segment Display Module

Arduino Project 034 - TM1637 4Digital 7Segment Display Module

A standard 4-digit 7-segment display is needed for clock, timer and counter projects, but it usually...

Arduino Project 003 - LED Traffic Light

Arduino Project 003 - LED Traffic Light

You are now going to create a set of traffic lights that will change from green to red, via amber, a...

Arduino Project 024 -  LCD Temperature Display

Arduino Project 024 - LCD Temperature Display

This project is a simple demonstration of using an LCD to present useful information to the user—in...

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 Project 023D - Liquid Crystal Displays - Custom Character

Arduino Project 023D - Liquid Crystal Displays - Custom Character

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

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

发表评论

访客

看不清,换一张

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