Cov txheej txheem:

Arduino Piano: 5 Kauj Ruam
Arduino Piano: 5 Kauj Ruam

Video: Arduino Piano: 5 Kauj Ruam

Video: Arduino Piano: 5 Kauj Ruam
Video: Coca cola touch Arduino piano keyboard tutorial 2024, Kaum ib hlis
Anonim
Arduino Piano
Arduino Piano
Arduino Piano
Arduino Piano

nyob zoo cov phooj ywg koj ib txwm xav ua piano, yog tias yog, tom qab ntawd koj nyob hauv qhov chaw raug.

Khoom siv

1. Arduino

2.8 ohms hais lus

3. Rub cov neeg tawm tsam (1k - 10k yuav ua tau zoo xwb)

4.8 tact hloov

5. Breadboard thiab veroboard

Kauj Ruam 1: Rub Tawm thiab Rub Tawm Resistors

Rub tawm thiab Rub Tawm Resistors
Rub tawm thiab Rub Tawm Resistors
Rub tawm thiab Rub Tawm Resistors
Rub tawm thiab Rub Tawm Resistors

rub tawm resistor

Qhov no yog cov tiv thaiv uas ua rau lub xeev cov laj thawj ntawm tus pin HIGH thaum tus pin tsis txuas lossis tsis muaj lub xeev.

Rub cov resistors

Cov tshuaj tiv thaiv no pab ua kom lub xeev cov laj thawj ntawm tus lej qis thaum tsis txuas lossis thaum tus pin tsis muaj lub xeev.

Txhawm rau kawm paub ntau ntxiv txog rub thiab rub cov neeg tawm tsam mus ntsib

playground.arduino.cc/CommonTopics/PullUpD…

Nco tseg: muaj peb lub xeev pins uas yog HIGH, LOW THIAB ntab lossis qhov tseem ceeb. Thaum tus pin yog HIGH nws txhais tau tias nws ntawm 5v (rau Arduino MCU), thaum LOW txhais tau tias nws nyob ze 0v lossis GND, thaum rau ntab txhais tau tias nws tsis muaj lub xeev nws tsis yog HIGH LOSSIS LOW.

NCO TSEG: hauv cov lus qhia no peb yuav siv rub tawm cov resistors

Kauj Ruam 2: Tone Fuction thiab Zaus

Arduino suab fuction

Qhov haujlwm no yog siv los tsim txhua zaus ntawm Arduino tus pin

suab nrov (tus pin, zaus, sijhawm lossis ncua sijhawm);

Piv txwv li lub suab (9, 3100, 100);

noTone ()

Cov haujlwm no tau siv thaum koj tsis xav ua suab nrov lossis zaus ntawm tus pin tshwj xeeb.

noTone (tus pin);

Piv txwv noTone (9); // qhov no yuav ua si tsis muaj suab nrov lossis zaus ntawm tus pin 9.

NCO TSEG: Yog tias koj xav hloov tus pin siv rau lub suab kom ntseeg tau tias nws yog PWM tus pin.

tone (pwm pin, zaus, ncua);

noTone (pwm pin); Txhawm rau nrhiav tawm pwm tus pin rau Arduino xauj qhov haujlwm. Piv txwv li tshawb nrhiav (pwm tus pin ntawm Arduino pro mini). Tsuas yog hloov cov pro mini rau Arduino micro tswj koj siv. Yog xav paub ntxiv txog pwm mus ntsib

Kauj Ruam 3: Momentary Switches (Kev Hloov Siab)

Momentary Switches (Hloov Hloov Tact)
Momentary Switches (Hloov Hloov Tact)

Qhov hloov pauv no thaum nias tau txuas nrog rau lub sijhawm koj nias lawv tam sim koj tshem koj txhais tes lawv tau txuas nrog. Yog xav paub ntau ntxiv txog yuav siv lub tswv yim hloov pauv li cas rub cov vis dis aus hauv cov lus qhia no

Kauj ruam 4: Schematics

Schematics
Schematics

yog tias koj tab tom siv cov cai nrog sab hauv rub tawm cov neeg tawm tsam tsis quav ntsej rub tawm cov neeg tawm tsam hauv qhov kev qhia no. Nco ntsoov txuas ib tus coj ntawm koj tus neeg hais lus rau pwm tus pin 9 lossis tus pin pwm koj siv thiab lwm tus rau GND. yog tias koj tus neeg hais lus yog polarized txuas qhov zoo coj koj tus pin pwm thiab tus pin tsis zoo rau GND.

Kauj ruam 5: Code

Txoj cai thib ob tau hloov kho tag nrho los ntawm kuv rau cov uas tsis muaj cov neeg tawm tsam siv los rub tawm cov neeg tawm tsam

Code ib lub npe yog Arduino piano.zip, thaum code2 yog piano.zip

Ua tsaug rau kev nyeem ntawv. Ua si koj lub piano kom txog thaum koj tus ntsuj plig dhia mus zoo siab.

Kuv tsis tuaj yeem kos kuv li YouTube video, tab sis koj tuaj yeem nkag mus los ntawm qhov txuas no

www.youtube.com/embed/apsuFn0Wp1g

Pom zoo: