Mundarija:

O'yin maydonchasi yordamida tug'ilgan kunni tabriklash: 3 qadam
O'yin maydonchasi yordamida tug'ilgan kunni tabriklash: 3 qadam

Video: O'yin maydonchasi yordamida tug'ilgan kunni tabriklash: 3 qadam

Video: O'yin maydonchasi yordamida tug'ilgan kunni tabriklash: 3 qadam
Video: DEDAKTIV ДЕДАКТИВ УЙИН OʻYIN. BOLALAR UCHUN GUGURT QUTIDAN YASASH 2024, Noyabr
Anonim
Image
Image
Kodni qo'shish
Kodni qo'shish

Adafruit -ning Arduino -ga mos keladigan, O'yin maydonchasida Happy Birthday musiqasini qanday ijro etish mumkin.

Tug'ilgan kun qutisiga kutilmagan sovg'a qo'yish uchun menga kichkina narsa kerak edi

1 -qadam: Kodni qo'shish

Kodni qo'shish
Kodni qo'shish

Ushbu kodni Arduino IDE -ga nusxalash va joylashtirish, keyin faylga cpBirthday nomini berish

/*Tug'ilgan kuning bilan qo'shiq! Adafruit -ning O'yin maydonchasi bilan ishlash o'zgartirildi

Qo'shiqni ijro etish uchun O'yin maydonchasidagi o'ng tugmani bosish kifoya

CP uchun Tone kutubxonasi uchun qo'llanma yozgani uchun Mayk Barelaga rahmat

Uning qo'llanmasini bu erda topishingiz mumkin: https://learn.adafruit.com/circuit-playground-music/the-sound-of-music */

#qo'shish #"pitches.h" ni qo'shish

// Musiqa eslatmalari:

int melodi = {NOTE_G3, NOTE_G3, NOTE_A3, NOTE_G3, NOTE_C4, NOTE_B3, NOTE_G3, NOTE_G3, NOTE_A3, NOTE_G3, NOTE_D4, NOTE_C4, NOTE_G3, NOTE_G3, NOTE_G4, NOTE_E4, NOTE_C4, NOTE_C4, NOTE_B4 NOTE_C4, NOTE_D4, NOTE_C4};

// eslatmalar davomiyligi: 4 = chorak eslatma, 8 = sakkizinchi eslatma va boshqalar:

int noteDurations = {8, 8, 4, 4, 4, 2, 8, 8, 4, 4, 4, 2, 8, 8, 4, 4, 4, 4, 3, 8, 8, 4, 4, 4, 2};

bo'sh o'rnatish () {

CircuitPlayground.begin ();

}

void loop () {

if (CircuitPlayground.rightButton ()) {for (int thisNote = 0; thisNote <26; thisNote ++) {int noteDuration = 1000/noteDurations [thisNote]; // eslatma davomiyligini hisoblash uchun (1 soniya yozuv turiga bo'linadi) CircuitPlayground.playTone (ohang [thisNote], noteDuration); // eslatmalarni farqlash uchun ular orasidagi minimal vaqtni belgilang. int pauseBetweenNotes = noteDuration * 1.60; kechikish (pauseBetweenNotes); noTone (8); }}}

Keyin Brett Xagman tomonidan yozilgan ro'yxatlar va ularning chastotalari bo'lgan pitches.h faylini yangi tab va nom qo'shing.

-quyidagilarni nusxa ko'chiring va faylga joylashtiring

-saqla

/*********************************************** *Ommaviy doimiylar ********************************************* **/

#define NOTE_B0 31 #devetine NOTE_C1 33 #devetine NOTE_CS1 35 #de NOTEINE NOTE_D1 37 #de NOTEINE NOTE_DS1 39 #deinine NOTE_E1 41 #deFine NOTE_F1 44 #de NOTEFINE NOTE_FS1 46 #deFine NOTE_G1 49 #efine NOTEINEEFSEEEFEE511 # NOTE_B1 62 #define NOTE_C2 65 #devetine NOTE_CS2 69 #de NOTINE NOTE_D2 73 #de NOTINE NOTE_DS2 78 #deinine NOTE_E2 82 #de NOTINE NOTE_F2 87 #de NOTINE NOTE_FS2 93 #deFINE NOTE_G2 98 #deFine NOTE_GS2 104 #define2 #define NOTE_C3 131 #devetine NOTE_CS3 139 #devetine NOTE_D3 147 #de NOTINE NOTE_DS3 156 #define NOTE_E3 165 #deFine 175 #define NOTE_FS3 185 #define NOTE_G3 196 #de NOTE NOTE_GS3 208 #3define NOTE_C4 262 #devetine NOTE_CS4 277 #devetine NOTE_D4 294 #de NOTINE NOTE_DS4 311 #devetine NOTE_E4 330 #define NOTE_F4 349 #devetine NOTE_FS4 370 #define NOTE_G4 392 #de NOTINE NOTE_GS4 415 NOT4ine4444 # NOTE_CS5 554 ta'rifi NOTE_D5 587 #ta'rifi NOTE_DS5 622 #ta'rifi NOTE_E5 659 #ta'rifi NOTE_F5 698 #ta'rifi NOTE_FS5 740 #ninig NOTE_G5 784 #ta'rifi NOTE_GS5 831 #ta'rifi NOTE_A5 880 ning aniqligi88 ta 1109 #define NOTE_D6 1175 #devetine NOTE_DS6 1245 #define NOTE_E6 1319 #devetine NOTE_F6 1397 #deinine NOTE_FS6 1480 #define NOTE_G6 1568 #de NOTINE NOTE_GS6 1661 #devetine NOTE_A6 1760 #NOTEFINE_EEEEEEEEEEEE_EE_AECE6_17 NOTE_D7 2349 #devetine NOTE_DS7 2489 #devetine NOTE_E7 2637 #devetine NOTE_F7 2794 #deinine NOTE_FS7 2960 #de NOTINE NOTE_G7 3136 #de NOTINE NOTE_GS7 3322 #deinine NOTE_A7 3520 #efine NOTE_AS7 NOT8Engine8388 4699 #define NOTE_DS8 4978

2 -qadam: Kodni yuklang

Kodni yuklang
Kodni yuklang

Adafruit -dan ushbu qo'llanmada aytib o'tilganidek, O'yin maydonchasini qo'llab -quvvatlaganingizga ishonch hosil qiling.

-Plitalar ostidagi Adafruit Circuit PLayground -ni va uning COM portini tanlang

-Yuklash -ni bosing

3 -qadam: Portativ qiling

Portativ qiling
Portativ qiling

- Men kartani quvvat bilan ta'minlash uchun 3 x AAA batareya ushlagichini yoqish/o'chirish tugmachasi va 2 pinli JST ulagichidan foydalandim.

Kodni xohlaganingizcha o'zgartiring.

- Savollar, mulohazalar, iltifotlar va so'rovlar qabul qilindi:):

Tavsiya: