Cov txheej txheem:

MIDI2LED - MIDI Tswj LED Sawb Teeb nyhuv: 6 Kauj Ruam
MIDI2LED - MIDI Tswj LED Sawb Teeb nyhuv: 6 Kauj Ruam

Video: MIDI2LED - MIDI Tswj LED Sawb Teeb nyhuv: 6 Kauj Ruam

Video: MIDI2LED - MIDI Tswj LED Sawb Teeb nyhuv: 6 Kauj Ruam
Video: ? Что такое многополосный 6 атомный хронометраж ? То 2024, Kaum ib hlis
Anonim
MIDI2LED - MIDI Tswj LED Sawb Teeb Lub Teeb
MIDI2LED - MIDI Tswj LED Sawb Teeb Lub Teeb

Nov yog kuv thawj qhov kev qhia, yog li nrog kuv.

Kuv nyiam ua suab paj nruag, thiab hauv cov xwm txheej zoo li chav ua yeeb yam nyob hauv chav, Kuv nyiam nws thaum muaj lub teeb pom kev zoo ua ke nrog qhov kuv ua si. Yog li kuv tau tsim lub thawv Arduino-based uas ua rau LED kab teeb ci hauv qhov xim tsis xwm yeem thaum kuv ntaus ntawv ntawm kuv cov keyboard MIDI, thiab qhov twg kuv ntaus ntawv.

Khoom siv

  • Arduino Ib
  • Arduino protoshield
  • MIDI txuas
  • 1N4148 diode
  • 6N138 opto txuas
  • resistors: 2x 220 Ohm, 1x 10kOhm, 1x 470Ohm
  • WS2812B LED sawb (60 LEDs)
  • qee cov xov hlau seem
  • cua sov ntsws tubing
  • casing haum rau Arduino (Kuv siv lub thawv yas txuas)

Koj yuav tsum tau

  • soldering hlau thiab solder
  • MIDI keyboard thiab MIDI cable

Kauj Ruam 1: Cov Khoom Siv Hluav Taws Xob

Cov Electronics
Cov Electronics

Lub Circuit Court yog qhov yooj yim heev. Nws suav nrog tus txheej txheem MIDI cov tswv yim (sab laug ntawm Arduino) thiab kev txuas mus rau LED sawb (sab xis ntawm Arduino). Tso txhua qhov ntawm daim protoshield, muaj ntau qhov chaw. Nws feem ntau pom zoo kom siv cov khoom siv hluav taws xob sab nraud los txhawb lub zog LED, tab sis kuv pom tias thaum koj ua si, tsuas muaj ob peb LEDs nyob rau tib lub sijhawm, yog li muaj tsis muaj teeb meem hauv kev siv Arduino +5V / GND raws li lub zog tso tawm. (Sim ua kom tsis txhob tsoo txhua tus yuam sij tib lub sijhawm, thiab nrog kev nrawm nrawm.;-)) Yog tias koj txiav txim siab siv lub zog hluav taws xob sab nraud, yooj yim txuas nws mus rau Arduino +5V thiab GND pins. Qee tus neeg pom zoo kom ntxig rau 100uF capacitor (tsis tau qhia hauv schematic) ntawm ob kab no.

Muab cov khoom seem tso rau hauv daim phiaj tiv thaiv thiab txuas cov kab hluav taws xob LED raws li qhia hauv kab lus.

Kauj Ruam 2: Txuas LED Sawb

Txuas LED Sawb
Txuas LED Sawb

Nws yog ib qho tseem ceeb uas yuav tsum txuas qhov kawg - qhov kawg nkag mus - ntawm cov kab hluav taws xob LED mus rau hauv Circuit Court. Kuv lub pluaj muaj tus poj niam txuas ua cov tswv yim, thiab muaj cov voos me me tag nrho ua ke kom deb ntawm cov tswv yim. Ntawm qhov tsim tawm, muaj tus txiv neej txuas (kom tuaj yeem txuas nws mus rau lwm lub pluaj, uas peb tsis xav tau), yog li kuv txiav qhov ntawd thiab muab nws txuas rau peb kab txuas los ntawm Arduino. Siv cov cua sov ua kom sov los khi peb txoj hlua txuas rau LED kab ua ke, thiab ua kom lawv pom tsawg dua.

Cov hlua LED kuv siv los nrog cov kab xev nplaum ntawm nws nraub qaum, yog li nws tuaj yeem yooj yim lo rau sab nraum qab ntawm MIDI keyboard.

Kauj Ruam 3: Hloov Kho Txoj Haujlwm rau Koj Cov Keyboard

Hloov kho Txoj Haujlwm rau Koj Cov Keyboard
Hloov kho Txoj Haujlwm rau Koj Cov Keyboard
Hloov kho Txoj Haujlwm rau Koj Cov Keyboard
Hloov kho Txoj Haujlwm rau Koj Cov Keyboard

Tej zaum koj yuav tsum hloov kho kab LED thiab Arduino code rau koj cov keyboard. Kuv muaj 76 tus yuam sij, thiab qhov ntev ntawm kab txaij yuav luag raws qhov dav ntawm cov keyboard. Yog koj muaj eg 61 tus yuam sij, tej zaum koj yuav xav tau ib kab ntawv luv dua. LED sawb tuaj yeem txiav nruab nrab ntawm ob qho LEDs. Tsuas yog xyuas kom tseeb tias koj tau txiav tawm qhov raug, nws muaj qhov kawg nkag (nrog tus poj niam txuas) thiab qhov tso tawm kawg (nrog tus txiv neej txuas), koj yuav tsum khaws cov tswv yim xaus. rau

  • NUMBER_OF_LEDS mus rau tus lej ntawm LEDs sab laug hauv koj kab txaij tom qab txiav qhov kawg,
  • NUMBER_OF_KEYS rau tus lej ntawm koj cov keyboard, thiab
  • MIN_KEY rau MIDI suab tus lej ntawm koj tus yuam sij qis tshaj. Koj tuaj yeem pom qhov no hauv cov keyboard cov neeg siv phau ntawv; lossis siv cov cuab yeej uas qhia MIDI tus lej cim, zoo li KMidiMon rau Linux, lossis Pocket MIDI rau lub qhov rais lossis Mac; lossis sim tawm qhov sib txawv kom txog rau thaum lub cuab yeej teb rau txhua tus yuam sij ntawm koj cov keyboard

Kauj ruam 4: Arduino Code

Tus lej Arduino siv MIDI lub tsev qiv ntawv (v4.3.1) los ntawm Plaub caug Xya Cov Teeb Meem thiab Adafruit NeoPixel lub tsev qiv ntawv (v1.3.4) los ntawm Adafruit. Nruab cov tsev qiv ntawv no siv Arduino IDE. Tom qab ntawv sau cov cai thiab xa nws mus rau Arduino yam tsis muaj daim ntaub thaiv txuas nrog (tus optocoupler txuas nrog RX tus pin, uas cuam tshuam qhov rub tawm). Fais fab Arduino ntawm USB cable (Kuv siv USB phab ntsa wart).

Yog tias koj xav hloov kho txoj cai raws li koj nyiam, ntawm no yog cov lus qhia luv luv seb nws ua haujlwm li cas: Hauv txhua lub voj, MIDI cov tswv yim tau nyeem tawm. Yog tias tau txais Kev Ceeb Toom Rau lossis Ceeb Toom Tawm, MyHandleNoteOn lossis MyHandleNoteOff cov haujlwm tau hu. Lawv ob leeg hu rau qhov hloov tshiabVelocityArray muaj nuj nqi, uas khaws cov nrawm (piv txwv li nyuaj npaum li cas koj tau ntaus tus yuam sij) ntawm tus lej yuam sij. Yog tias qhov nrawm tshaj qhov tau khaws cia ua ntej, cov xim ntawm LED sib xws tau teeb tsa rau "xim tam sim no". Tom qab MIDI cov xwm txheej tau raug daws, txoj haujlwm hloov tshiabLedArray raug hu. Qhov no hloov kho qhov "xim tam sim no" (qhov liab, ntsuab thiab xiav qhov tseem ceeb ntawm kev hloov ntawm nws tus kheej hauv txoj kab ncaj qha, kom txog thaum qis lossis siab kawg mus txog, nyob rau qhov twg qhov nrawm rau kev hloov pauv tau teeb tsa tus lej tsis raug), maj mam txo qhov nrawm ntawm cov ntawv sau tseg, thiab hloov kho cov xim qhov tseem ceeb ntawm txhua LED uas yuav tsum tau hloov nws cov xim (vim yog sau ntawv tshiab, lossis txo qhov nrawm). Kev ua yeeb yam showLedArray hloov cov xim rau Adafruit_NeoPixel tus qauv hu ua "pixels" thiab ua qhov tseeb LEDs qhia cov xim hauv cov qauv pixels.

Kauj Ruam 5: Muaj peev xwm txhim kho…

Ib txoj haujlwm tseem tsis tau tiav. Muaj ib yam uas tuaj yeem ua tau los txhim kho nws:

  • Cov protoshield muaj ob peb ntu nws yog qhov pov tseg tiag; ib tus tuaj yeem ua tiav cov txiaj ntsig zoo ib yam nrog Arduino Nano thiab 15x7 qhov PCB ntxiv rau qee tus poj niam tus pin headers.
  • Qee qhov MIDI cov cim tau ploj. Yog tias nws yog NoteOn, LED sib xws yuav tsis pom kev; yog tias nws yog NoteOff, nws yuav tsis tawm mus (yog vim li cas kuv thiaj li qhia qhov txo qis ntawm qhov nrawm, uas ua kom ntseeg tau tias LEDs yuav tsis nyob tas mus li). Kuv tseem tabtom sim txheeb xyuas qhov laj thawj. Tej zaum nws yog lub sijhawm teeb meem, thiab MIDI.read () yuav tsum raug hu ntau zaus.
  • Qee qhov MIDI cov cim qhia tau nyeem tsis raug, piv txwv li qhov tsis raug ntawm LEDs teeb. Yuav txuas nrog lub ntsiab lus saum toj no. Xav tau qee qhov kev tshawb nrhiav.
  • Lub Circuit Court tau tsim los muab cov txiaj ntsig pom kev zoo uas tsis muaj kev cuam tshuam ntau ntawm cov neeg siv (sib nrug los ntawm kev ua si cov keyboard). Txawm li cas los xij, kuv tuaj yeem xav txog qhov ntxiv lub hwj chim uas tau nyeem tawm (siv ib qho ntawm Arduino cov lus sib piv) uas koj tuaj yeem hloov qhov nrawm tshaj plaws uas cov xim hloov pauv (tam sim no #txhais raws li MAX_COLOR_CHANGE_SPEED = 20). Los yog ntsuas lub sijhawm nruab nrab nruab nrab ntawm ob qho lus ceeb toom tshwm sim, thiab hloov MAX_COLOR_CHANGE_SPEED raws li - hauv cov nkauj qeeb, xim yuav tsum hloov qeeb dua.

Kauj ruam 6: Ua tiav

Fais fab Arduino ntawm USB cable (Kuv siv USB phab ntsa wart). Txuas koj MIDI keyboard rau MIDI nkaus, thiab pib rockin '. Saib kuv ua suab paj nruag me ntsis (pun, zoo li nws yog, npaj).

Pom zoo: