Cov txheej txheem:

Qhov Muag Qhov Muag Pw Tsaug Suab Nkauj: 5 Kauj Ruam
Qhov Muag Qhov Muag Pw Tsaug Suab Nkauj: 5 Kauj Ruam

Video: Qhov Muag Qhov Muag Pw Tsaug Suab Nkauj: 5 Kauj Ruam

Video: Qhov Muag Qhov Muag Pw Tsaug Suab Nkauj: 5 Kauj Ruam
Video: Zoo Siab Nrog Koj - Paj Tsua Thoj [ Official MV ] Nkauj Tawm Tshiab 2022 2024, Kaum ib hlis
Anonim
Qhov muag daim npog qhov muag Music
Qhov muag daim npog qhov muag Music

Qhov no yog txoj haujlwm tso cai rau koj tsaug zog hmo ntuj zoo dua, cia siab rau qhov qeeb version Christmas nkauj ntawm daim npog qhov muag.

Kauj Ruam 1: Npaj Cov Khoom

Npaj Cov Khoom
Npaj Cov Khoom

Khoom siv

1. Arduino Leonardo

2. Cov Khoom Hluav Taws Xob

3. Daim npog qhov muag (qhov koj nyiam tshaj)

Kauj ruam 2: Txhim Kho

Txhim Kho
Txhim Kho

Tsim koj li Arduino Leonardo Board

Muab Cov Khoom Siv Hluav Taws Xob Hluav Taws Xob ncaj qha rau ntawm qhov chaw kuv kos

(Nco ntsoov tias nws yuav tsis txav ib ncig)

Kauj Ruam 3: Sijhawm rau Txoj Haujlwm

Sijhawm rau Txoj Haujlwm
Sijhawm rau Txoj Haujlwm

Nov yog lub sijhawm rau txoj haujlwm, qhib koj "Arduino" ntawm koj lub khoos phis tawj thiab ncaj qha luam qhov program hauv no.

int buzzerPin = 13; int tempo = 200; char notes = "eeeeeeegcde fffffeeeeddedg"; int lub sijhawm = {1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2};

void playTheShit (char note, int duration) {char notesName = {'c', 'd', 'e', 'f', 'g'}; int tones = {261, 293, 329, 349, 392};

rau (int i = 0; i <sizeof (tones); i ++) {// Bind the note took from the char array to the array notesName if (note == notesName ) {// Bind the notesName to tones tone (buzzerPin, tones , ntev); }}}

teeb tsa tsis muaj dab tsi () {pinMode (buzzerPin, OUTPUT); }

void loop () {// Luam theej txhua tus char los ntawm "sau ntawv" rau (int i = 0; i <= sizeof (notes) -1; i ++) {if (notes == '') {// Yog pom qhov chaw nws so qeeb (sijhawm * tempo); } lwm {playTheShit (sau ntawv , ntev * tempo); }

// Pauses ntawm cov ntawv ncua ((tempo*2)*ntev ); }}

Kauj ruam 4: Plug

Plug
Plug

Txuas lub roj teeb rau koj lub Arduino board

Xyuas kom lub program ua haujlwm

Yog tias tsis yog, tsuas yog tawm tswv yim

Kauj Ruam 5: Ua Koj Lub Qhov Muag Daim Npog

Ua Koj Qhov Muag Qhov Muag
Ua Koj Qhov Muag Qhov Muag

Kaw lub suab ntawm koj daim npog qhov muag

Muab tso rau, thiab tsaug zog

Sau koj lub npe ua ntej lwm tus nyiag.

Pom zoo: