Cov txheej txheem:

Kev Paub Txuj Ci Lvl 2: 5 Cov Kauj Ruam
Kev Paub Txuj Ci Lvl 2: 5 Cov Kauj Ruam

Video: Kev Paub Txuj Ci Lvl 2: 5 Cov Kauj Ruam

Video: Kev Paub Txuj Ci Lvl 2: 5 Cov Kauj Ruam
Video: Nraug txuj kev hlub 2024, Kaum ib hlis
Anonim
Kev Paub Txuj Ci Lvl 2
Kev Paub Txuj Ci Lvl 2
Kev Paub Txuj Ci Lvl 2
Kev Paub Txuj Ci Lvl 2

Qhov no yuav yog kev qhia nrawm los pab koj ua tiav qib 2 kev siv hluav taws xob zoo. Koj tsis tas yuav ua qhov no raws nraim li! Koj tuaj yeem hloov cov khoom/cov khoom raws li koj nyiam tab sis yuav muaj lub luag haujlwm hloov pauv cov cai kom nws ua haujlwm. Kuv yuav ntxiv cov lus pom rau cov cai kom piav qhia txhua ntu ua dab tsi.

Qhov kawg yog microcomputer. Peb siv Arduino Nano. Qhov no tuaj yeem hloov pauv rau Arduino Uno lossis lwm yam microcontroller. Kev ua haujlwm yuav txawv thiab koj yuav tsum lav ris kom lwm lub computer ua haujlwm.

Cov hlua coj yog nyob hauv lub hnab nyiaj nyob saum lub MHD tub rau khoom tub rau khoom. Lub microphone tseem nyob sab hauv lub hnab nrog LEDs. Thaum koj ua tiav thov xa lawv tuaj ntawm no!

Khoom siv

  1. Microcomputer

    Arduino Nano Cov

  2. Hlau

    1. 7f2x cev

      1. 2 x dub
      2. 2x Roob
      3. 3x ntau yam xim
  3. LED Sawb

    Ib zaug ntxiv peb tsuas muaj ib qho. Nws yuav nrog Microphone

  4. Microphone

    Peb tsuas muaj ib qho thiaj li muab nws tso rau thaum kawg! Nws yuav nyob hauv tub rau khoom tub rau khoom

Kauj ruam 1: Microcomputer

Microcomputer
Microcomputer

Txhawm rau pib peb yuav tsum xis nyob nrog ntu ntawm Arduino Nano. Raws li pom hauv daim duab, muaj ob sab tseem ceeb rau tus tswj. Tsuas yog ib feem peb txhawj xeeb txog yog raws li hauv qab no:

  • +5V
  • GND
  • GND
  • 3V3 (qhov no tuaj yeem tshwm sim li 3.3V tab sis txhais tau tib yam nkaus)
  • D2
  • D3
  • D4
  • Mini USB (nyiaj ntsaws qhov kawg)

Kauj ruam 2: LED Sawb

LED Sawb
LED Sawb
LED Sawb
LED Sawb
LED Sawb
LED Sawb
LED Sawb
LED Sawb

Pib los ntawm qhov tau txais qhov kawg ntawm cov hlua coj. Qhov no yuav tsum muaj lub ntsaws dub (nrog 4 xaim nkag mus rau hauv nws) thiab tom qab ntawd ob lub xov tooj cua tsis zoo (1x daj, 1x liab). Peb yuav tsuas yog saib xyuas txog lub ntsaws dub. Qhia nws kom nyob hauv qhov kev txiav txim no los ntawm sab laug mus rau sab xis: liab, xiav, ntsuab, daj. Cov xim no sib haum nrog VCC, D0, C0, GND. Siv tus poj niam sab ntawm cov xov hlau thawb cov xaim dub mus rau GND, liab rau VCC thiab xim sib txawv mus rau nruab nrab ob.

** Thaum txuas cov xov hlau, xyuas kom tseeb tias lub tab nyiaj tau tig rov los! Qhov no yuav pab lawv swb rau ntawm tus pin. (Pom hauv daim duab thawj)

Tom qab ntawd peb yuav coj lwm tus poj niam sab thiab txuas rau Nano. Txuas GND xaim los ntawm kab hlua LED mus rau GND ib sab ntawm D2. Tom qab ntawd coj VCC xaim thiab txuas nws mus rau +5V tus pin. Txuas C0 thiab D0 tus pin los ntawm LED mus rau D2 thiab D3 tus pin ntawm Nano. Qhov chaw ntsaws tuaj yeem pom hauv daim duab thib peb thiab thib plaub.

Kauj Ruam 3: Txuas lub Microphone

Txuas lub Microphone
Txuas lub Microphone
Txuas lub Microphone
Txuas lub Microphone
Txuas lub Microphone
Txuas lub Microphone

** NCO TSEG **

Cov xov hlau tsis txaus thaum thaij duab. Kuv yuav hloov daim duab no thaum ua tau los cuam tshuam cov lus qhia kom zoo dua. Nov yog cov xim hlau hauv cov lus qhia piv rau cov xim hauv cov duab:

  • liab -> xim av
  • dub -> dub
  • xim -> grey

Lub microphone yuav txuas nrog tib yam li LED Sawb tab sis nrog tsuas yog 1 tus pin tus lej hloov ob.

Lub sijhawm no peb yuav tsum txuas tus VCC tus pin los ntawm lub mic mus rau 3V3 tus pin ntawm nano siv lub xov tooj liab. Tom qab ntawd GND tus pin ntawm lub mic mus rau GND ntawm nano siv cov xaim dub thiab thaum kawg OUT tus pin ntawm lub mic mus rau D4 tus pin ntawm nano nrog cov xim xaim.

Kauj Ruam 4: Arduino IDE

Siv cov khoos phis tawj ze tshaj ntawm 3D tshuab luam ntawv, qhib Arduino IDE. Cov khoos phis tawj no muaj software tshwj xeeb teeb tsa los tswj peb cov hlua LED. Tom qab ntawd siv lub micro USB txuas nano rau lub khoos phis tawj.

  1. Nyem Cov Cuab Yeej nyob rau sab saum toj
  2. Tom qab ntawv hauv Pawg Thawj Coj, nyem Arduino Nano
  3. Hauv qab Tus Txheej Txheem nyem ATmega328P (Old Bootloader)

    Yog tias qhov no tsis ua haujlwm ces xaiv ATmega328P

  4. Thaum kawg, hauv qab Chaw nres nkoj, nyem qhov kev xaiv tsuas yog qhia.

Thaum qhov ntawd tau xaiv tag nrho, theej thiab muab cov cai no tso rau hauv lub qhov rai kos duab (qhov uas nws hais tias tsis muaj teeb tsa teeb tsa () thiab tsis muaj dab tsi voj ()). Tom qab ntawd nyem lub xub taw qhia rau sab xis (nws tuaj yeem pom sab xis hauv qab cov ntawv hloov kho cov khoom). Qhov no yuav xa cov cai rau koj nano.

#suav nrog // Txheeb xyuas qhov twg D pins siv. const uint8_t clockPin = 2; const uint8_t dataPin = 3; const uint8_t micPin = 4; // Tsim lub hom phiaj rau kev sau ntawv mus rau LED sawb. APA102 ledStrip; // Teeb tus lej ntawm LEDs los tswj. const uint16_t ledCount = 60; uint8_t coj; // Suab const int sampleWindow = 50; // Piv txwv qhov dav dav hauv mS (50 mS = 20Hz) tsis kos npe rau tus qauv; // Tsim kom tsis txhob tuav cov xim (3 bytes ib xim). rgb_color xim [ledCount]; // Teeb lub teeb ci ntawm lub teeb (qhov siab tshaj plaws yog 31 tab sis tuaj yeem ua qhov muag tsis pom kev). const int ci ntsa iab = 12; teeb tsa tsis muaj dab tsi () {Serial.begin (9600); } void loop () {sib npaug (); ledStrip.write (xim, coj, suav, ci ntsa iab); } void equilizer () {unsigned ntev startMillis = millis (); // Pib ntawm lub qhov rai piv txwv tsis tau kos npe rau hauv peakToPeak = 0; // ncov-rau-ncov qib unsigned int signalMax = 0; unsigned int signalMin = 1024; uint8_t lub sij hawm = millis () >> 4; // sau cov ntaub ntawv rau 50 mS thaum (millis () - startMillis <sampleWindow) {qauv = analogRead (micPin); // pov tawm qhov kev nyeem tsis raug yog (qauv signalMax) {signalMax = qauv; // txuag tsuas yog qib max} lwm qhov yog (qauv <signalMin) {signalMin = piv txwv; // txuag tsuas yog qib qis}}} peakToPeak = signalMax - signalMin; // max - min = peak -peak amplitude memset (xim, 0, sizeof (xim)); // tshem tawm cov xim ntawm LED sawb leds = ranges (peakToPeak); // hu rau kab kom pom pes tsawg LEDS kom pom kev uint32_t stripColor = peakToPeak/1000 + peakToPeak%1000; rau (uint16_t i = 0; i <= leds; i ++) {xim = hsvToRgb ((uint32_t) stripColor * 359 /256, 255, 255); // ntxiv cov xim rov qab mus rau kab txaij thaum tsuas yog teeb pom kev zoo li qhov xav tau. }} rgb_color hsvToRgb (uint16_t h, uint8_t s, uint8_t v) {uint8_t f = (h % 60) * 255 /60; uint8_t p = (255 - s) * (uint16_t) v / 255; uint8_t q = (255 - f * (uint16_t) s / 255) * (uint16_t) v / 255; uint8_t t = (255 - (255 - f) * (uint16_t) s / 255) * (uint16_t) v / 255; uint8_t r = 0, g = 0, b = 0; hloov ((h / 60) % 6) {rooj plaub 0: r = v; g = tsi; b = peb; tawg; rooj plaub 1: r = q; g = v; b = peb; tawg; rooj plaub 2: r = p; g = v; b = tau; tawg; rooj plaub 3: r = p; g = qw; b = v; tawg; rooj plaub 4: r = t; g = peb; b = v; tawg; rooj plaub 5: r = v; g = peb; b = qw; tawg; } rov qab rgb_color (r, g, b); } uint8_t ranges (uint8_t vol) {yog (vol> 800) {rov qab 60; } lwm yog (vol> 700) {rov qab 56; } lwm yog (vol> 600) {rov qab 52; } lwm yog (vol> 500) {rov qab 48; } lwm yog (vol> 400) {rov qab 44; } lwm yog (vol> 358) {rov 40; } lwm yog (vol> 317) {rov qab 36; } lwm yog (vol> 276) {rov qab 32; } lwm yog (vol> 235) {rov qab 28; } lwm yog (vol> 194) {rov 24; } lwm yog (vol> 153) {xa rov qab 20; } lwm yog (vol> 112) {rov qab 16; } lwm yog (vol> 71) {rov qab 12; } lwm yog (vol> 30) {rov qab 8; } lwm {rov qab 4; }}

Kauj ruam 5: Thaum Ua tiav

Ua haujlwm zoo! Siv daim duab ntawm nws txhua yam ua haujlwm. Yog tias cov hlua coj tsis ua kom pom kev zoo tom qab ntawd lub hau ntswj nyob tom qab ntawm lub microphone tau hloov kho. Koj tuaj yeem hloov txoj cai los kho qhov no (thov kev pab yog tias koj xav tau) tab sis tsis xav tau. Yog tias koj xav khaws txoj haujlwm, txuas rau lub microphone thiab coj kab txaij tau qhia hauv qab no. Peb xav tau cov neeg nyob ntawm Hub rau lwm tus neeg ua haujlwm kom ua tiav ib yam.

Tam sim no ua ntej disassembling txhua yam rov txuas nano rau lub khoos phis tawj thiab ua raws cov theem hauv Arduino IDE:

  • Nyem File
  • Piv txwv
  • Yooj yim
  • Blink
  • Thaum ua tiav nyem lub pob upload

Qhov no yog txhawm rau kom txhua tus ua tiav tag nrho cov txheej txheem thiab tsis yog txuas cov xov hlau nkaus xwb. Tam sim no disassemble txhua yam thiab muab nws rov qab qhov twg koj pom nws!

Txuas:

Microphone

LEDs yuav raug ntxiv thaum kuv muaj qhov txuas

Pom zoo: