Cov txheej txheem:

Studio Nruas: 5 Kauj Ruam
Studio Nruas: 5 Kauj Ruam

Video: Studio Nruas: 5 Kauj Ruam

Video: Studio Nruas: 5 Kauj Ruam
Video: Tus Neeg Ruam - R-Lin Thoj | New Song [ Official MV ] Nkauj Tawm Tshiab 2023 Hmong Song 2023 2024, Hlis ntuj nqeg
Anonim
Studio Nruas
Studio Nruas

Drummers yuav siv sijhawm ntau teev thiab xyaum ua haujlwm… Tab sis tsis yog txhua tus tuaj yeem muaj lub nruas hauv tsev: qhov chaw thiab suab nrov yog teeb meem loj!

Vim li no, peb xav tsim lub portable thiab ntsiag to drumkit uas koj tuaj yeem ua si hauv tsev.

Lub nruas nruas no yooj yim heev rau siv, koj tsuas yog yuav tsum tsoo cov pawm thiab nws yuav zoo li lub nruas tiag! Nws kuj tseem tuaj nrog cov zaub uas koj tuaj yeem pom lub ncoo twg koj tab tom tsoo. Thiab yog tias koj xav siv nws nyob rau hauv hom ntsiag to, tsuas yog txuas koj lub mloog pob ntseg rau lub khoos phis tawj!

Kauj ruam 1: Yam Koj Yuav Tsum Tau

Cov ntaub ntawv

  • Arduino Ib
  • Cov qhob cij
  • Ib co xaim
  • 5x paj
  • 5 x 1M Ohm resistors
  • 5 jar qab
  • Eva ua npuas ncauj
  • Ua npuas ncauj pawg thawj coj saib

KEV KAWM:

  • Arduino IDE Cov
  • Ua

*Txhawm rau rub cov program saum toj no rau koj lub khoos phis tawj, ua raws qhov txuas hauv qab no:

  • https://www.arduino.cc/en/main/software
  • https://www.arduino.cc/en/main/software

Kauj Ruam 2: Sib dhos Circuit

Sib dhos Circuit
Sib dhos Circuit
Sib dhos Circuit
Sib dhos Circuit

Ua ntej tshaj plaws peb yuav tsum tau muab tshuaj txhuam rau lub piezos (GND mus rau qhov daj thiab qhov sib piv tus lej xaim mus rau ntu dawb ntawm piezo).

Peb yuav siv lub khob cij los txuas txhua yam.

Txuas tus tiv thaiv thiab cov xov hlau ntawm piezo raws li qhia hauv daim duab saum toj no. Tom qab ntawd txuas GND xaim ntawm lub khob cij rau GND ntawm Arduino. Thaum kawg, txuas txhua lub xaim ntawm piezo mus rau tus pin analog ntawm koj Arduino raws li qhia hauv qab no.

Piezos txuas nrog analog pins:

  • Caixa = A0;
  • Charles = A1;
  • Tomtom = A2;
  • Tsoo = A3;
  • Bombo = A4;

Kauj ruam 3: Program Nws

Program Nws
Program Nws

Peb txiav txim siab los tsim peb tus kheej cov zaub rau lub nruas nruas es tsis txhob siv cov program ua ntej. Peb tau siv Kev Ua Haujlwm rau qhov no.

Peb tau teeb tsa nws kom thaum lub piezo raug tsoo, lub suab ntawm lub nruas sib haum yuav nrov. Ib qho ntxiv, tus qauv nruas sib xws yuav ci rau ntawm qhov screen.

Koj yuav tsum tau ntshuam ua suab, thiab ua cov tsev qiv ntawv txuas.

Tsis txhob hnov qab ntxiv lub nruas suab rau hauv cov ntaub ntawv tais ceev tseg!

ARDUINO CODE

// PIEZOS tau txuas rau ANALOG PINS

const int caixa = A0;

const int charles = A1;

const int tomtom = A2;

const int tsoo = A3;

const koj bombo = A4;

const int pib = 100; // tus nqi pib los txiav txim siab thaum lub suab kuaj pom yog khob lossis tsis yog

// Nyeem thiab khaws cia qhov muaj nuj nqis nyeem los ntawm tus lej PIN

int caixaReading = 0;

int charlesReading = 0;

int tomtomReading = 0;

int tsooReading = 0;

int bomboReading = 0;

void teeb tsa () {

Serial.begin (9600); // siv qhov chaw nres nkoj

}

void voj () {

// nyeem lub sensor thiab khaws nws hauv qhov sib txawv sensorReading:

caixaReading = analogRead (caixa);

// yog tias lub sensor nyeem ntawv ntau dua li qhov pib:

yog (caixaReading> = threshold) {

// Yog tias koj ntaus CAIXA, xa 0 mus rau txheej txheem

Serial.print ("0,");

Serial.println (caixaReading);

}

charlesReading = analogRead (charles);

yog (charlesReading> = threshold) {

// Yog tias koj ntaus tus ntawv, xa 1 mus rau txheej txheem

Serial.print ("1,");

Serial.println (caixaReading);

}

tomtomReading = analogRead (tomtom);

yog (tomtomReading> = threshold) {

// Yog tias koj ntaus CAIXA, xa 2 mus rau txheej txheem

Serial.print ("2,");

Serial.println (tomtomReading);

}

crashReading = analogRead (tsoo);

yog (crashReading> = threshold) {

// Yog tias koj ntaus CAIXA, xa 3 mus rau txheej txheem

Serial.print ("3,");

Serial.println (crashReading);

}

bomboReading = analogRead (foob pob);

yog (bomboReading> = 15) {

// Yog tias koj ntaus CAIXA, xa 4 mus rau txheej txheem

Serial.print ("4,");

Serial.println (bomboReading);

}

ncua (10); // ncua kom tsis txhob overloading qhov chaw nres nkoj serial tsis

}

TSO CAI CODE

// QHOV TSEEB Suab thiab Cov Ntawv Qub Qub

ntshuam txheej txheem.sound.*;

ntshuam ua.serial.*;

Serial myPort; // Tsim cov khoom los ntawm chav kawm Serial

Txoj hlua val; // Cov ntaub ntawv tau txais los ntawm cov chaw nres nkoj

// DRUM SOUNDS

SoundFile caixa;

SoundFile charles;

SoundFile tomtom;

SoundFile sib tsoo;

SoundFile foob pob;

// DRUMS STUDIO IMAGES

Cov duab img0;

PIB img1;

Cov duab img2;

Cov duab img3;

Duab img4;

Duab img5;

Duab img6;

// DRUMS STUDIO WAVES VARIABLES

ntab n = 0;

ntab n2 = 1;

ntab n3 = 2;

ntab n4 = 3;

ntab n5 = 4;

ntab y = 0;

ntab y2 = 1;

ntab y3 = 2;

ntab y4 = 3;

ntab y5 = 4;

void teeb tsa ()

{

// Qhib qhov chaw twg yog qhov koj tab tom siv

Txoj hlua portName = Serial.list () [0]; // hloov 0 mus rau 1 lossis 2 thiab lwm yam kom phim koj qhov chaw nres nkoj

myPort = Serial tshiab (qhov no, portName, 9600);

// DRUMS STUDIO CONSOLA

loj (720, 680);

keeb kwm yav dhau (15, 15, 15);

strokeWeight (2);

// LOAD DRUM STUDIO IMAGES

img0 = loadImage ("drumsstudio.png");

img1 = loadImage ("res.png");

img2 = loadImage ("caixa.png");

img3 = loadImage ("charles.png");

img4 = loadImage ("tomtom.png");

img5 = loadImage ("tsoo.png");

img6 = loadImage ("foob pob.png");

// LOAD SOUNDS

caixa = tshiab SoundFile (qhov no, "caixa.aiff");

charles = tshiab SoundFile (qhov no, "charles.aiff");

tomtom = tshiab SoundFile (qhov no, "tomtom.aiff");

tsoo = tshiab SoundFile (qhov no, "crash.aiff");

bombo = SoundFile tshiab (qhov no, "bombo.aiff");

}

void kos ()

{

// TITULO DRUMS STUDIO

duab (img0, 125, 0);

// WAVES DRAWING

yog (y> 720) // Pib yoj dua

{

y = 0;

y2 = 1;

y3 = 2;

y4 = 3;

y5 = 4;

}

sau (0, 10);

rect (0, 0, dav, qhov siab);

// Dejamos sau rau blanco para

// lub hnub qub ci ntsa iab

sau (255);

mob stroke (250, 255, 3);

point (y, (qhov siab -40) + sin (n) * 30);

n = n + 0.05;

y = y + 1;

mob stroke (250, 255, 3);

point (y2, (qhov siab -40) + cos (n2) * 30);

n2 = n2 + 0.05;

y2 = y2 + 1;

mob stroke (250, 255, 3);

point (y3, (qhov siab -40) + sin (n3) * 30);

n3 = n3 + 0.05;

y3 = y3 + 1;

mob stroke (250, 255, 3);

point (y4, (qhov siab -40) + cos (n4) * 30);

n4 = n4 + 0.05;

y4 = y4 + 1;

mob stroke (250, 255, 3);

point (y5, (qhov siab -40) + sin (n5) * 30);

n5 = n5 + 0.05;

y5 = y5 + 1;

// DIBUJO BATERIA SIN NINGUNA PARTE ILUMINADA

duab (img1, 0, 80);

// Ua rau lwm tus rau txhua qhov nkag

yog (myPort.available ()> 0)

{// Yog tias muaj cov ntaub ntawv, val = myPort.readStringUntil ('\ n'); // nyeem nws thiab khaws nws hauv val

println (tau);

Txoj hlua daim ntawv = cais (val, ','); // Qhib ib daim ntawv teev npe rau kev noj txhua tus nqi nkag

yog (list! = tsis muaj)

{

if (list [0].equals ("0")) {// yog tias koj ntaus caixa

caixa.play (); // Ua suab caixa

duab (img2, 0, 80); // Caixa tau ci ntsa iab hauv qhov screen

println ("caixa"); // luam nws tawm hauv lub console

} lwm tus yog (npe [0].equals ("1")) {// yog tias koj ntaus charles

charles.play (); // Ua suab charles

duab (img3, 0, 80); // Cov charles tau ci ntsa iab hauv qhov screen

println ("charles"); // luam nws tawm hauv lub console

} lwm tus yog (npe [0].equals ("2")) {// Yog tias koj ntaus tomtom

tomtom.play (); // Ua suab tomtom

duab (img4, 0, 80); // Tomtom tau ci ntsa iab hauv qhov screen

println ("tomtom"); // luam nws tawm hauv lub console

} lwm tus yog (npe [0].equals ("3")) {// Yog tias koj tsoo qhov sib tsoo

crash.play (); // Ua suab nrov sib tsoo

duab (img5, 0, 80); // Crash tau ci ntsa iab hauv qhov screen

println ("tsoo"); // luam nws tawm hauv lub console

} lwm tus yog (npe [0].equals ("4")) {// yog tias koj tsoo lub foob pob

bombo.play (); // Ua suab foob pob

duab (img6, 0, 80); // Bombo tau ci ntsa iab hauv qhov screen

println ("foob pob"); // luam nws tawm hauv lub console

}

}

}

}

Kauj ruam 4: Tsim Nws

Tsim Nws
Tsim Nws
Tsim Nws
Tsim Nws
Tsim Nws
Tsim Nws
Tsim Nws
Tsim Nws

Rau qhov ua tiav ntawm tsab ntawv, peb muaj

siv cov khoom niaj hnub los ua kom yooj yim rau txheej txheem, tab sis ib txwm saib rau kev ua haujlwm thiab ua tiav zoo.

Thawj kauj ruam yog txhawm rau txuas cov hlua txuas rau lub piezoelectric, txiav cov no kom ntev txaus kom muaj kev ywj pheej thaum npaj lub roj teeb ntawm lub rooj lossis qhov uas peb mus xyaum.

Tom qab qee qhov kev tshawb fawb, peb tau pom tias nws yog ib qho tseem ceeb uas lub ncoo zoo tshaj tawm qhov kev co ntawm txhua qhov cuam tshuam rau piezoelectric, yog li cov khoom xws li ntoo lossis yas tau muab pov tseg. Thaum kawg, peb xaiv siv lub hau hlau rau cov zaub mov kaus poom, uas ua raws li lawv lub luag haujlwm thiab muaj lub ntsej muag haum rau lawv lub hom phiaj.

Sim nrog cov nruas thiab raws li xav tau, cov kev cuam tshuam tau nrov nrov thiab txav deb ntawm kev daws teeb meem ntawm lub nruas ntsiag to. Txhawm rau daws nws, peb npog lub ntsej muag nrog Eva ua npuas ncauj, txiav mus rau qhov ntev ntawm qhov nruab nrab ib puag ncig ntawm lub hau. Nws tau lo nrog daim kab xev ob tog nyias nyias txaus kom cov nyem tsis pom thaum ua si. Ib qho ntxiv, raws li ntug ntawm lub hau tseem ua suab nrov nrov uas tiv thaiv peb los ntawm kev ua si yooj yim, peb tso qee qhov me me ntawm cov kua nplaum kub yaj rau ntawm ntug kom tiv thaiv lub ncoo los ntawm kev plam thiab muag muag txhua qhov cuam tshuam ntau li ntau tau.

Txhawm rau tiv thaiv plaub daim ntaub los ntawm kev tawg thaum kov, peb koom nrog lawv ua khub los ntawm txoj hlua xov uas nkag los ntawm sab, tsau los ntawm sab hauv nrog cov txiv ntoo me me. Qhov teeb meem thaum peb pib ua si yog vim tias nws yog cov khoom siv hlau, nws kis tau qhov kev co los ntawm ib lub ncoo mus rau lwm qhov, yog li thaum peb ua si ib leeg, nws tus khub ua suab nrov tib lub sijhawm.

Thaum kawg peb tshem cov pas nrig thiab pom tias nws txaus thiab muaj txiaj ntsig ntau dua los siv lub piezo cable nws tus kheej ua lub koomhaum.

Raws li rau tus pedal, peb tau muaj lub tswv yim pib ntawm tuav lub piezo ntawm cov qhaub cij; kom tsis txhob cuam tshuam ncaj qha ntawm piezo tawm tsam hauv av. Txhawm rau ua qhov no peb glued lub piezo rau ntawm cov phaj ntoo thiab glued lwm PVC phaj ntawm qhov loj me, uas peb tau ua qhov tawg me me kom yooj yim thiab haum rau ob lub piezo thiab cable.

Thaum xub thawj peb siv PVC rau ob daim hlau, tab sis tom qab ob peb qhov kev sim peb pom tias cov khoom no nqus tau ntau dhau thiab cuam tshuam nws mus rau piezo.

Txhawm rau kom tsis txhob muaj tus ko taw xoob thiab txav mus raws li koj nqis tes, peb tau txiav txim siab muab cov roj hmab tso rau nruab nrab ntawm cov qhaub cij kom tuav tus pedal rau peb txhais taw thiab xyuas kom txhua tus mob stroke ntawm lub nruas.

Thaum kawg, kom ua tiav qhov ua tau zoo dua, peb tau tsim lub thawv me me rau peb tus kheej uas nyob hauv lub protoboard thiab arduino. Nov yog qhov uas 5 txoj kab hluav taws xob nkag los ntawm ib sab thiab tso cai rau USB txuas txuas mus rau lwm qhov. Nws tau teeb tsa hauv daim duab plaub dub, kom nws yooj yim tuav thiab txuas ntxiv nrog kev zoo nkauj dub thiab dawb ntawm tag nrho cov qauv.

Pom zoo: