Cov txheej txheem:

Arduino Metronome: 4 Kauj Ruam
Arduino Metronome: 4 Kauj Ruam

Video: Arduino Metronome: 4 Kauj Ruam

Video: Arduino Metronome: 4 Kauj Ruam
Video: Washboard Metronome 2024, Hlis ntuj nqeg
Anonim
Image
Image

Thaum kawm paub cov cuab yeej siv suab paj nruag tshiab thaum tseem yog menyuam yaus, muaj ntau yam tshiab uas yuav tsum tsom mus rau. Ua kom nrawm nrawm nrawm yog ib qho ntawm lawv. Tsis pom qhov ua kom tiav thiab yooj yim metronome txhais tau tias yog kev zam txim zoo tshaj plaws los pib tsim dua nrog kuv cov menyuam. Hauv Cov Lus Qhia no koj yuav pom cov lus piav qhia ua haujlwm, cov npe teev nrog webshop txuas thiab tus nqi, daim duab thaiv rau kev sib dhos, thiab ua tiav Arduino qhov chaws.

Kauj Ruam 1: Nqe lus piav qhia

Daim Ntawv Teev Npe
Daim Ntawv Teev Npe

Nws yuav yog qhov zoo kom muaj cov cuab yeej siv metronome nrog cov haujlwm hauv qab no los siv nws hauv tsev lossis hauv tsev kawm suab paj nruag yooj yim.

  • Kev cog lus me me kom haum rau qhov chaw me me nyob rau sab saum toj lossis ib sab ntawm cov twj paj nruas,
  • Roj teeb ua haujlwm, muaj zog thiab nqa tau mus ib puag ncig,
  • Yooj yim teeb tsa txawm tias rau menyuam yaus, BPM tus nqi ib txwm tso tawm,
  • Hloov kho cov neeg ntaus ib feeb nrog lub pob qhov rooj, nce txog 240 BPM
  • Lub ntsej muag hnov nrog tswj lub ntim,
  • Hom uas ntsiag to rau kev xyaum mloog lub mloog pob ntseg,
  • Pom kev tawm tswv yim ntawm cov neeg ntaus (1/4, 2/4, 3/3, 4/4, 6/8, thiab lwm yam) txog 8 LEDs,
  • Nrog lossis tsis muaj tus hais lus tseem ceeb, nrog kev pom thiab hnov suab.

Hloov mus, hom metronome yuav pib ntawm 60 BPM qhia ntawm lub vijtsam me me thiab cia qhov nrawm nrawm los ntawm lub pob qhov rooj ntawm 10 thiab 240. Neopixels qhia qhov ntaus hauv xiav LEDs thaum lub suab nrov zuam. Nias lub pob qhov rooj yuav hloov mus rau txoj kev hloov kho thiab LEDs ntsuab yuav qhia qhov teeb tsa kev teeb tsa. Teb pob qhov rooj yuav nce lossis txo qhov kev sib tw (2/2, 3/3, 4/4, 6/8, thiab lwm yam). Saum 8 LEDs, txuas ntxiv raws lub moos raws, cov lus hais ua ntej yuav qhib, thiab thawj LED yuav qhia qhov no liab. Ua tus hais lus tseem ceeb yuav muaj lub suab tawm tswv yim ib yam. Nws tuaj yeem raug tua los ntawm kev tig rov qab-clockwise. Nias lub pob qhov rooj yuav hloov rov qab los ntawm kev hloov kho hom mus rau hom metronome.

Kauj Ruam 2: Daim Ntawv Teev Npe

Koj yuav xav tau ib rooj plaub. Ib qho duab lossis qhov loj tuaj yeem yuav tau, tab sis peb muaj cov ntaub ntawv dub hlau zoo ntawm phau ntawv qub VGA hloov pauv ntawm tus phooj ywg. Cov seem ntawm cov seem tau teev tseg hauv qab no.

  • 9V Roj Teeb, USD 1.50
  • Roj teeb txuas cable, USD 0, 16
  • Arduino Nano nrog tus pin headers, USD 2.05
  • Nano IO Extension Shield, USD 1, 05
  • Mini swb hloov rau lub zog, USD 0.15
  • Piezo buzzer, USD 0, 86
  • Adafruit Neopixel WS2812 8-ntsis, USD 1, 01
  • OLED Zaub 128x64, USD 1, 53
  • Teb encoder, USD 0, 50
  • Dupont cables F/F, USD 0, 49

Tag nrho tus nqi ntawm cov khoom siv tsawg dua USD 10, -

Kauj Ruam 3: Daim Kab Xev

Daim duab thaiv
Daim duab thaiv

Siv Nano IO Extension Board txhawm rau kom tsis txhob cuam tshuam nrog ntau qhov sib txuas GND thiab VCC. Qhov tsawg kawg yuav tsum tau siv rau Nano tus pin headers thiab rau Neopixel module txuas. Kev siv Dupont cov xov hlau tso cai rau kev sib txuas ruaj khov rau seem ntawm cov thaiv raws li qhia hauv daim duab. Lub roj teeb 9V txuas nrog GND thiab VIN, tom kawg los ntawm kev hloov lub zog hluav taws xob. Cov qauv encoder teb tau muaj khawm hloov ua ke, uas tau qhia cais hauv daim duab kom nkag siab yooj yim ntawm kev txuas lawv li cas. Ib feem teb (CLK thiab DT) txuas nrog PIN2 thiab PIN3 feem, vim tias cov no tsuas yog NANO tus pin muaj peev xwm cuam tshuam kev tuav. Teb GND txuas nrog Nano's GND PIN ntawm chav kawm. Lub khawm hloov ua ke tau txuas nrog PIN4. Piezo buzzer txuas nrog PIN5 thiab GND. Adafruit Neopixel module txuas nrog PIN7 thiab nws VIN thiab GND rau Nano's 5V thiab GND feem. OLED me me tau txuas nrog I2C npav npav, uas yog PIN A4 thiab A5 rau SDA thiab SDL. VCC thiab GND mus rau Nano's 5V thiab GND tau kawg. Qhov ntawd xaus peb Dupont thaiv.

Kauj ruam 4: Arduino Source Code

Arduino Source Code
Arduino Source Code

// Metronome, Leading Accent, Visual & Audible Tact - 2019 Peter Csurgay

#include #include #include #include #include "TimerOne.h" #define SCREEN_WIDTH 128 #define SCREEN_HEIGHT 64 #define OLED_RESET -1 // Reset pin #(lossis -1 yog sib koom Arduino reset pin) Adafruit_SSD1306 zaub (SCREEN_WIDTH, & Hlau, OLED_RESET); #define pin_neopixel 7 #define NUMPIXELS 8 #define BRIGHTNESS 32 Adafruit_NeoPixel pixels = Adafruit_NeoPixel (NUMPIXELS, pin_neopixel, NEO_GRB + NEO_KHZ800); #define IDLE_11 0 #define SCLK_01 1 #define SCLK_00 2 #define SCLK_10 3 #define SDT_10 4 #define SDT_00 5 #define SDT_01 6 int xeev = IDLE_11; #define CLK 2 #define DT 3 #define pin_switch 4 #define pin_buzzer 5 int bpm = 60; int bpmFirst = 0; // LED Thaum xub thawj, Tawm ntawm tus so… int tack = 4; bool leadingTack = tsis tseeb; int pos = 0; int curVal = 0; int prevVal = 0; teeb tsa tsis muaj dab tsi () {pixels.begin (); pinMode (tus pin_buzzer, OUTPUT); Timer1.initialize (1000000*60/bpm/2); Timer1.attachInterrupt (buzztick); pinMode (CLK, INPUT_PULLUP); pinMode (DT, INPUT_PULLUP); pinMode (pin_switch, INPUT_PULLUP); attachInterrupt (digitalPinToInterrupt (CLK), rotaryCLK, CHANGE); attachInterrupt (digitalPinToInterrupt (DT), rotaryDT, CHANGE); yog (! display.begin (SSD1306_SWITCHCAPVCC, 0x3C)) {// Chaw Nyob 0x3D rau 128x64 rau (;;); // Tsis txhob ua ntxiv, voj mus ib txhis} display.clearDisplay (); display.display (); } void loop () {if (digitalRead (pin_switch) == LOW) {ncua (100); thaum (digitalRead (pin_switch) == QAU); ncua (100); Timer1.detachInterrupt (); showGreenTacks (); thaum (digitalRead (pin_switch) == HIGH) {yog (curVal> prevVal) {tack+= 1; yog (tack> 8) {yog (leadingTack) tack = 8; lwm tus {leadingTack = muaj tseeb; tug = 1; }}} lwm tus yog (curValprevVal) {bpm+= 2; yog (bpm> 240) bpm = 240; } lwm tus yog (curVal = 100) display.print (""); lwm tus display.print (""); display.print (bpm); display.display (); } tsis muaj dabtsis buzztick () {yog (bpmFirst == 0) {int ntim = 4; yog (leadingTack && pos == 0) ntim = 8; rau (int i = 0; i

Pom zoo: