{"id":3331,"date":"2018-04-08T18:40:11","date_gmt":"2018-04-08T15:40:11","guid":{"rendered":"https:\/\/devrearsivi.com\/index.php\/?p=3331"},"modified":"2018-04-18T21:17:46","modified_gmt":"2018-04-18T18:17:46","slug":"arduino-ile-polifonik-ses-olusturma","status":"publish","type":"post","link":"https:\/\/devrearsivi.com\/arduino-ile-polifonik-ses-olusturma\/","title":{"rendered":"Arduino ile Polifonik Ses Olu\u015fturma"},"content":{"rendered":"
\"\"<\/a>
Merhaba arkada\u015flar, Polifonik ses diye tabir edilen \u015fey ayn\u0131 anda birden fazla ses tonunun olu\u015fturulmas\u0131na denir. Bu sistem arduino ile olu\u015fturulmas\u0131 hayal olmaktan \u00e7\u0131kabilir.<\/figcaption><\/figure>\n

\"\"<\/p>\n

 <\/p>\n

 <\/p>\n

Merhaba arkada\u015flar, Polifonik ses diye tabir edilen \u015fey ayn\u0131 anda birden fazla ses tonunun olu\u015fturulmas\u0131na denir. Bu sistem arduino ile olu\u015fturulmas\u0131 hayal olmaktan \u00e7\u0131kabilir.<\/p>\n

Arduinomuzla projelerimizde genellikle bir adet hoparl\u00f6r ile kullan\u0131yorduk asl\u0131na bakarsan\u0131z tek bir hoparl\u00f6r ile bu seslerin \u00e7\u0131kar\u0131lmas\u0131 m\u00fcmk\u00fcn de\u011fil. Bundan dolay\u0131 birden fazla hoparl\u00f6r kullanmam\u0131z gerekecek.<\/p>\n

Projemizde arduino ile 3 adet hoparl\u00f6r kullan\u0131lm\u0131\u015ft\u0131r.<\/p>\n

Bu hoparl\u00f6rlerin hangisinin aktif oldu\u011funu belirtmek i\u00e7in 3 adet LED kullan\u0131ld\u0131.<\/p>\n

 <\/p>\n

 <\/p>\n

Kullan\u0131lan Malzemeler<\/strong><\/em><\/p>\n

Arduino UNO<\/p>\n

 <\/p>\n

\"\"<\/p>\n

3x Hoparl\u00f6r3x LED<\/p>\n

\"\"<\/p>\n

3x Led<\/p>\n

\"\"<\/p>\n

3x 100 ohm Diren\u00e7<\/p>\n

\"\"<\/p>\n

Uygulama\u00a0<\/strong><\/em><\/p>\n

\"\"<\/a><\/p>\n

#include <Tone.h><\/p>\n

Tone solo;
\nTone bass;
\nTone rythm;<\/p>\n

const int t = 600; \/\/ quater note duration
\nconst int tt = t*2;
\nconst int t14 = round(t*1\/4);
\nconst int t24 = round(t*2\/4);
\nconst int t34 = round(t*3\/4);<\/p>\n

const int bassLedPin = 15; \/\/ bass led signal pin (aka A1)
\nconst int rythmLedPin = 17; \/\/ rythm led signal pin (aka A3)
\nconst int soloLedPin = 19; \/\/ solo led signal pin (aka A5)<\/p>\n

void wait(Tone t)
\n{
\nwhile (t.isPlaying()) { }
\n}<\/p>\n

int bassLedState = LOW;
\nvoid switchBassLed()
\n{
\nif (bassLedState == LOW)
\nbassLedState = HIGH;
\nelse
\nbassLedState = LOW;
\ndigitalWrite(bassLedPin, bassLedState);
\n}<\/p>\n

int rythmLedState = LOW;
\nvoid switchRythmLed()
\n{
\nif (rythmLedState == LOW)
\nrythmLedState = HIGH;
\nelse
\nrythmLedState = LOW;
\ndigitalWrite(rythmLedPin, rythmLedState);
\n}<\/p>\n

int soloLedState = LOW;
\nvoid switchSoloLed()
\n{
\nif (soloLedState == LOW)
\nsoloLedState = HIGH;
\nelse
\nsoloLedState = LOW;
\ndigitalWrite(soloLedPin, soloLedState);
\n}<\/p>\n

void setup(void)
\n{
\npinMode(14, OUTPUT); \/\/ led ground pin (aka A0)
\npinMode(16, OUTPUT); \/\/ led ground pin (aka A2)
\npinMode(18, OUTPUT); \/\/ led ground pin (aka A4)
\npinMode(bassLedPin, OUTPUT); \/\/ bass led signal pin
\npinMode(rythmLedPin, OUTPUT); \/\/ rythm led signal pin
\npinMode(soloLedPin, OUTPUT); \/\/ solo led signal pin<\/p>\n

pinMode(2, OUTPUT); \/\/ solo buzzer ground pin
\npinMode(9, OUTPUT); \/\/ rythm buzzer ground pin<\/p>\n

solo.begin(6); \/\/ solo buzzer signal pin
\nbass.begin(12); \/\/ bass buzzer signal pin
\nrythm.begin(0); \/\/ rythm buzzer signal pin<\/p>\n

solo.play(NOTE_D4, t34); switchSoloLed();
\nwait(solo);
\nsolo.play(NOTE_D4, t14); switchSoloLed();
\nwait(solo);
\n}<\/p>\n

void loop(void)
\n{<\/p>\n

bass.play(NOTE_G3, t); switchBassLed();
\nrythm.play(NOTE_G4, t24); switchRythmLed();
\nsolo.play(NOTE_E4, t); switchSoloLed();
\nwait(rythm);
\nrythm.play(NOTE_B4, t14); switchRythmLed();
\nwait(rythm);
\nrythm.play(NOTE_D5, t14); switchRythmLed();
\nwait(rythm);
\nbass.play(NOTE_B3, t); switchBassLed();
\nrythm.play(NOTE_G4, t24); switchRythmLed();
\nsolo.play(NOTE_D4, t); switchSoloLed();
\nwait(rythm);
\nrythm.play(NOTE_B4, t14); switchRythmLed();
\nwait(rythm);
\nrythm.play(NOTE_D5, t14); switchRythmLed();
\nwait(rythm);
\nbass.play(NOTE_D4, t); switchBassLed();
\nrythm.play(NOTE_G4, t24); switchRythmLed();
\nsolo.play(NOTE_G4, t); switchSoloLed();
\nwait(rythm);
\nrythm.play(NOTE_B4, t14); switchRythmLed();
\nwait(rythm);
\nrythm.play(NOTE_D5, t14); switchRythmLed();
\nwait(rythm);<\/p>\n

bass.play(NOTE_D4, t); switchBassLed();
\nrythm.play(NOTE_D5, t24); switchRythmLed();
\nsolo.play(NOTE_FS4, tt); switchSoloLed();
\nwait(rythm);
\nrythm.play(NOTE_FS5, t14); switchRythmLed();
\nwait(rythm);
\nrythm.play(NOTE_A5, t14); switchRythmLed();
\nwait(rythm);
\nbass.play(NOTE_FS4, t); switchBassLed();
\nrythm.play(NOTE_D5, t24); switchRythmLed();
\nwait(rythm);
\nrythm.play(NOTE_FS5, t14); switchRythmLed();
\nwait(rythm);
\nrythm.play(NOTE_A5, t14); switchRythmLed();
\nwait(rythm);
\nbass.play(NOTE_A4, t); switchBassLed();
\nrythm.play(NOTE_D5, t24); switchRythmLed();
\nsolo.play(NOTE_D4, t34); switchSoloLed();
\nwait(rythm);
\nrythm.play(NOTE_FS5, t14); switchRythmLed();
\nwait(rythm);
\nrythm.play(NOTE_A5, t14); switchRythmLed();
\nsolo.play(NOTE_D4, t14); switchSoloLed();
\nwait(rythm);<\/p>\n

bass.play(NOTE_D4, t); switchBassLed();
\nrythm.play(NOTE_D5, t24); switchRythmLed();
\nsolo.play(NOTE_E4, t); switchSoloLed();
\nwait(rythm);
\nrythm.play(NOTE_FS5, t14); switchRythmLed();
\nwait(rythm);
\nrythm.play(NOTE_A5, t14); switchRythmLed();
\nwait(rythm);
\nbass.play(NOTE_FS4, t); switchBassLed();
\nrythm.play(NOTE_D5, t24); switchRythmLed();
\nsolo.play(NOTE_D4, t); switchSoloLed();
\nwait(rythm);
\nrythm.play(NOTE_FS5, t14); switchRythmLed();
\nwait(rythm);
\nrythm.play(NOTE_A5, t14); switchRythmLed();
\nwait(rythm);
\nbass.play(NOTE_A4, t); switchBassLed();
\nrythm.play(NOTE_D5, t24); switchRythmLed();
\nsolo.play(NOTE_A4, t); switchSoloLed();
\nwait(rythm);
\nrythm.play(NOTE_FS5, t14); switchRythmLed();
\nwait(rythm);
\nrythm.play(NOTE_A5, t14); switchRythmLed();
\nwait(rythm);<\/p>\n

bass.play(NOTE_G3, t); switchBassLed();
\nrythm.play(NOTE_G4, t24); switchRythmLed();
\nsolo.play(NOTE_G4, tt); switchSoloLed();
\nwait(rythm);
\nrythm.play(NOTE_B4, t14); switchRythmLed();
\nwait(rythm);
\nrythm.play(NOTE_D5, t14); switchRythmLed();
\nwait(rythm);
\nbass.play(NOTE_B3, t); switchBassLed();
\nrythm.play(NOTE_G4, t24); switchRythmLed();
\nwait(rythm);
\nrythm.play(NOTE_B4, t14); switchRythmLed();
\nwait(rythm);
\nrythm.play(NOTE_D5, t14); switchRythmLed();
\nwait(rythm);
\nbass.play(NOTE_D4, t); switchBassLed();
\nrythm.play(NOTE_G4, t24); switchRythmLed();
\nsolo.play(NOTE_D4, t34); switchSoloLed();
\nwait(rythm);
\nrythm.play(NOTE_B4, t14); switchRythmLed();
\nwait(rythm);
\nrythm.play(NOTE_D5, t14); switchRythmLed();
\nsolo.play(NOTE_D4, t14); switchSoloLed();
\nwait(rythm);<\/p>\n

bass.play(NOTE_G3, t); switchBassLed();
\nrythm.play(NOTE_G4, t24); switchRythmLed();
\nsolo.play(NOTE_D5, t); switchSoloLed();
\nwait(rythm);
\nrythm.play(NOTE_B4, t14); switchRythmLed();
\nwait(rythm);
\nrythm.play(NOTE_D5, t14); switchRythmLed();
\nwait(rythm);
\nbass.play(NOTE_B3, t); switchBassLed();
\nrythm.play(NOTE_G4, t24); switchRythmLed();
\nsolo.play(NOTE_B4, t); switchSoloLed();
\nwait(rythm);
\nrythm.play(NOTE_B4, t14); switchRythmLed();
\nwait(rythm);
\nrythm.play(NOTE_D5, t14); switchRythmLed();
\nwait(rythm);
\nbass.play(NOTE_D4, t); switchBassLed();
\nrythm.play(NOTE_G4, t24); switchRythmLed();
\nsolo.play(NOTE_G4, t); switchSoloLed();
\nwait(rythm);
\nrythm.play(NOTE_B4, t14); switchRythmLed();
\nwait(rythm);
\nrythm.play(NOTE_D5, t14); switchRythmLed();
\nwait(rythm);<\/p>\n

bass.play(NOTE_C4, t); switchBassLed();
\nrythm.play(NOTE_C5, t24); switchRythmLed();
\nsolo.play(NOTE_FS4, t); switchSoloLed();
\nwait(rythm);
\nrythm.play(NOTE_E5, t14); switchRythmLed();
\nwait(rythm);
\nrythm.play(NOTE_G5, t14); switchRythmLed();
\nwait(rythm);
\nbass.play(NOTE_E4, t); switchBassLed();
\nrythm.play(NOTE_C5, t24); switchRythmLed();
\nsolo.play(NOTE_E4, t); switchSoloLed();
\nwait(rythm);
\nrythm.play(NOTE_E5, t14); switchRythmLed();
\nwait(rythm);
\nrythm.play(NOTE_G5, t14); switchRythmLed();
\nwait(rythm);
\nbass.play(NOTE_G4, t); switchBassLed();
\nrythm.play(NOTE_C5, t24); switchRythmLed();
\nsolo.play(NOTE_C5, t34); switchSoloLed();
\nwait(rythm);
\nrythm.play(NOTE_E5, t14); switchRythmLed();
\nwait(rythm);
\nrythm.play(NOTE_G5, t14); switchRythmLed();
\nsolo.play(NOTE_C5, t14); switchSoloLed();
\nwait(rythm);<\/p>\n

bass.play(NOTE_G3, t); switchBassLed();
\nrythm.play(NOTE_G4, t24); switchRythmLed();
\nsolo.play(NOTE_B4, t); switchSoloLed();
\nwait(rythm);
\nrythm.play(NOTE_B4, t14); switchRythmLed();
\nwait(rythm);
\nrythm.play(NOTE_D5, t14); switchRythmLed();
\nwait(rythm);
\nbass.play(NOTE_D3, t); switchBassLed();
\nrythm.play(NOTE_G4, t24); switchRythmLed();
\nsolo.play(NOTE_G4, t); switchSoloLed();
\nwait(rythm);
\nrythm.play(NOTE_B4, t14); switchRythmLed();
\nwait(rythm);
\nrythm.play(NOTE_D5, t14); switchRythmLed();
\nwait(rythm);
\nbass.play(NOTE_FS3, t); switchBassLed();
\nrythm.play(NOTE_D5, t24); switchRythmLed();
\nsolo.play(NOTE_A4, t); switchSoloLed();
\nwait(rythm);
\nwait(rythm);
\nrythm.play(NOTE_FS5, t14); switchRythmLed();
\nwait(rythm);
\nrythm.play(NOTE_A5, t14); switchRythmLed();
\nwait(rythm);<\/p>\n

bass.play(NOTE_G3, t); switchBassLed();
\nrythm.play(NOTE_G4, t24); switchRythmLed();
\nsolo.play(NOTE_G4, tt); switchSoloLed();
\nwait(rythm);
\nrythm.play(NOTE_B4, t14); switchRythmLed();
\nwait(rythm);
\nrythm.play(NOTE_D5, t14); switchRythmLed();
\nwait(rythm);
\nbass.play(NOTE_B3, t); switchBassLed();
\nrythm.play(NOTE_G4, t24); switchRythmLed();
\nwait(rythm);
\nrythm.play(NOTE_B4, t14); switchRythmLed();
\nwait(rythm);
\nrythm.play(NOTE_D5, t14); switchRythmLed();
\nwait(rythm);
\nsolo.play(NOTE_D4, t34); switchSoloLed();
\nwait(solo);
\nsolo.play(NOTE_D4, t14); switchSoloLed();
\nwait(solo);<\/p>\n

}<\/p>\n

 <\/p>\n

\u00c7al\u0131\u015fma prensibi\u00a0<\/strong><\/em><\/p>\n