กลับไปหน้ารวมไฟล์
passive-buzzer-d3301c.md

So we learnt before how to use a active buzzer right?

Well now we will use a passive one which will play a nice melody!


🛠️ เจาะลึกเบื้องหลังการทำงาน (Deep Dive / Technical Analysis)

The Passive Buzzer Rickroll project is a lightweight, invisible prank device. It combines the tone() generation capabilities of the Arduino with a light sensor, remaining completely silent until someone opens a drawer or turns on a light switch.

Frequencies and Rhythms in C++

To make an electronic "beep" recognizable as a pop song, you need accurate math.

  1. The Header File: You include a pitches.h tab in your sketch, containing all the musical notes mapped to their hertz frequencies (e.g., #define NOTE_D4 294).
  2. The Melody Array: You compose the riff of the song int melody[] = {NOTE_C4, NOTE_D4, NOTE_F4, NOTE_D4...};.
  3. The Duration Array: You list the beats: 1/4 notes, 1/8 notes, etc.
  4. The Trigger Loop: You wait for a condition to be met (e.g., analogRead(lightSensor) > 500). When triggered, a for loop plays the arrays using the tone(pin, pitch, duration) function.

Concealment Hardware

  • ATtiny85 Microcontroller: The smaller the better! A huge Arduino Uno is too obvious to hide. You can program an 8-pin ATtiny85 using your Uno.
  • Passive Piezo Buzzer: Essential. Active buzzers can only play one terrible beep.
  • LDR (Photoresistor): The trigger mechanism.
  • Coin Cell Battery (CR2032).

Tape this to the bottom of your roommate's desk drawer, and wait for the hilarity to ensue when they open it!

ข้อมูล Frontmatter ดั้งเดิม

title: "Passive buzzer"
description: "Using a passive buzzer to make a nice tune"
author: "littlefalcon9"
category: ""
tags:
  - "easy tutorials"
  - "passive buzzer"
  - "kids"
  - "mega 2560"
views: 2924
likes: 0
price: 299
difficulty: "Easy"
components:
  - "1x Passive buzzer"
  - "1x ELEGOO UNO R3 Project Complete Starter Kit"
  - "1x Jumper wires (generic)"
tools: []
apps:
  - "1x Arduino Web Editor"
  - "1x Arduino IDE"
downloadableFiles: []
documentationLinks: []
passwordHash: "f3d71ad067859e103d4e58b093d0743cb055c5a977144760335e17ddf3b70904"
encryptedPayload: "U2FsdGVkX18XG2QL0/x6BwS5UlFlxHIx9HamYQ5MmBNFs5bysvFB0FCvxk3JU56OlZyWHrI4VH5XPTQlFgiOBJwpMf/SqNxU/T4fyVEzANvkW1M38hxyFqCmdV7FzpFR"
seoDescription: "Learn how to use a Passive buzzer with Arduino to create musical tunes and melodies for your electronics projects."
videoLinks: []
heroImage: "https://cdn.jsdelivr.net/gh/bigboxthailand/arduino-assets@main/images/projects/passive-buzzer-d3301c_cover.jpg"
lang: "en"