Arduino Musical Tune Generator Circuit

ลองใช้เครื่องมือของเราเพื่อกำจัดปัญหา





คุณสามารถใช้วงจรกำเนิดเสียงดนตรี Arduino เล็ก ๆ นี้สำหรับแอพพลิเคชั่นที่ต้องการเช่นการสร้างกระดิ่งประตูที่น่าสนใจเป็นแตรถอยหลังรถหรือกล่องดนตรีสำหรับให้ของขวัญใครสักคนหรือเพื่อความสนุกสนานส่วนตัว

ต้องใช้ฮาร์ดแวร์

ฮาร์ดแวร์ที่จำเป็นสำหรับโครงการมีดังต่อไปนี้:



  • บอร์ด Arduino หรือ Genuino
  • Piezo buzzer หรือลำโพง
  • สายเบ็ด

Arduino ขับเคลื่อนด้วยอินพุตแหล่งจ่ายไฟ 9V, 500mA ซึ่งอาจมาจากอะแดปเตอร์ SMPS AC เป็น DC มาตรฐานใดก็ได้หรือคุณสามารถลองใช้ที่ชาร์จโทรศัพท์มือถือของคุณก็ได้

Pin # 8 จาก Arduino สามารถกำหนดค่าได้โดยตรงกับลำโพงซึ่งจะต้องไม่ได้รับการจัดอันดับสูงกว่า 8 โอห์มและ 1 วัตต์



ดังนั้นสายไฟเส้นหนึ่งของลำโพงจะเชื่อมต่อกับขา # 8 ของบอร์ด Arduino และอีกสายหนึ่งไปที่เส้นลบหรือสายกราวด์ของบอร์ด

สำหรับ Amplified Output

สำหรับเสียงที่ดังขึ้นหรือขยายอย่างมหาศาลคุณสามารถกำหนดค่าพิน # 8 ด้วยสเตจไดรเวอร์ทรานซิสเตอร์ซึ่งประกอบด้วยทรานซิสเตอร์ TIP31 ซึ่งฐานอาจเชื่อมต่อกับพิน 8 ผ่านตัวต้านทาน 1K ตัวปล่อยลงกราวด์และตัวเก็บรวบรวมกับหนึ่งในสายไฟของ ลำโพงสายอีกด้านของ spaker เชื่อมต่อกับแหล่งจ่ายไฟบวกซึ่งเป็นแหล่งจ่ายไฟ 9V (+)

ตรวจสอบให้แน่ใจว่าลำโพงได้รับการจัดอันดับที่ 8 โอห์ม แต่ด้วยกำลังวัตต์ที่สูงกว่ามากอาจอยู่ที่ประมาณ 5 วัตต์สำหรับการสร้างการปรับแต่งเพลงแบบขยาย

ร่างนี้เขียนโค้ดเพื่อเล่นและสร้างแบบสุ่มจำนวนมาก
ท่วงทำนองตามลำดับโดยใช้มาตราส่วน pentatonic
/*
Musician
Plays a (fairly) random tune until the program is stopped.
8-ohm speaker on digital pin 8.
//Copyright (c) 2012 Jeremy Fonte
//This code is released under the MIT license
//https://opensource.org/licenses/MIT
*/
int randomNote = 131
int randomDuration = 2
int noteStep = 1
int notes[15]
void setup() {
pinMode(8, OUTPUT)
notes[1] = 131
notes[2] = 147
notes[3] = 165
notes[4] = 196
notes[5] = 220
notes[6] = 262
notes[7] = 294
notes[8] = 330
notes[9] = 392
notes[10] = 440
notes[11] = 523
notes[12] = 587
notes[13] = 659
notes[14] = 784
notes[15] = 880
randomNote = random(1, 15)
}
void loop() {
noteStep = random(-3, 3)
randomNote = randomNote + noteStep
if(randomNote <1) {
randomNote = random(1, 15)
}
else if(randomNote > 15) {
randomNote = random(1, 15)
}
randomDuration = random(1, 8)
// to calculate the note duration, take one second
// divided by the note type.
//e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
int noteDuration = 1000/randomDuration
tone(8, notes[randomNote],noteDuration)
// to distinguish the notes, set a minimum time between them.
// the note's duration + 30% seems to work well:
int pauseBetweenNotes = noteDuration * 1.30
delay(pauseBetweenNotes)
// stop the tone playing:
noTone(8)
}

แผนภาพการเชื่อมต่อสำหรับวงจรกำเนิดเสียงดนตรี Arduino ที่นำเสนอแสดงไว้ด้านล่าง:

Arduino Musical Tune Generator Circuit

สำหรับการฟังแบบขยายกำลังสูงการตั้งค่าเดียวกันนี้สามารถอัพเกรดได้ด้วยทรานซิสเตอร์กำลังดังที่ระบุในรูปต่อไปนี้:




คู่ของ: อธิบายวงจร Power Bank อย่างง่าย 4 แบบ ถัดไป: Arduino RGB Flowing Sequential Light Circuit