CODE | Piezo Sounder Alarm - Arduino Project 011

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

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 | Human Body Infrared Detector and Relay Light - Arduino Project 048

CODE | Human Body Infrared Detector and Relay Light - Arduino Project 048

Project 48 Human Body Infrared Detector and Relay LightThis Infrared Human Sensor referenc…

Electric Maker Beginner Tools Kit

Electric Maker Beginner Tools Kit

This assortment of tools has everything you need to get started tinkering with Sparkfun products and…

About Arduino Resources

About Arduino Resources

The Arduino platform benefits from an active user community that makes it easy to get help from fell…

CODE | Ultrasonic Distance Alarm - Arduino Project 040

CODE | Ultrasonic Distance Alarm - Arduino Project 040

The sensor consists of two primary components: a transmitter and a receiver . The transmitter is res…

Electric Maker and Coding Basic Tools and Knowledge

Electric Maker and Coding Basic Tools and Knowledge

电子制作|启程前的入门知识电子制作是一件充满乐趣和成就感的活动,也许在开始时会有一些挑战或者坎坷,慢慢的当你踏入电子制作的世界之后,我相信你肯定再也停不下脚步,本部分电子制作的入门知识将主要围绕:工具…

Post a Comment

Anonymous

Feel free to share your thoughts and opinions here.