• Notalar bо‘yicha
  • DASTURIY QISMI
  • Pezonurlatgich. Pezonurlatgichni boshqarish: tonni o‘zgartirish, davomiligini o‘zgartirish Ishdan maqsad




    Download 13,09 Kb.
    bet2/4
    Sana29.05.2024
    Hajmi13,09 Kb.
    #256824
    1   2   3   4
    Bog'liq
    Pezonurlatgich. Pezonurlatgichni boshqarish tonni o‘zgartirish,-www.fayllar.org

    tone() funksiyasi chiqishda berilgan chastotada tо‘g‘ri burchakli signal hosil qiladi (50% tо‘ldirish koeffitsiyenli). Bu funksiya shuningdek signal davrini ham bera oladi. Agarda signalning davri kо‘rsatilmagan bо‘lsa Tope () bо‘yicha funksiyasini chaqirilmaguncha signal hosil qilinaveradi. 2 jadvalda notaning birinchi va ikkinchi oktavalar uchun chastotalar qiymati berilgan.

    1- rasm. Pyezonurlatgichni Arduino ga ulanish sxemasi.


    Notalar bо‘yicha musiqani tuzamiz, melody[] massivga kiritiladi, notalar davrining rо‘yxatini duration [ ] massivga kiritiladi. Notalarni belgilangan axborot notes [ ] massivga kiritiladi, kerakli notalarga tegishli chastotalar haqidagi axborot frequency[ ] massiviga kiritiladi. PASTDA ESA sketch keltirilgan.

    2- rasm. Imperiya marshining bir qismi.


    DASTURIY QISMI
     // MELODIYA - nota massivi va davr massivi
    char melody [ ]={‘G’,’G’,’G’,’E’,’H’,’G’,’E’,’H’,’G’,’*’,
    d’,’d’,’d’,’e’,’H’,
    T’,’E’,’H’,’F’,
    g’,’G’,’G’,’g’,’t’,’e’,
    s’,’s’,’s’,’*’,’U’,’r’,’c’,’B’,
    H’,’A’,’H’,’*’,’E’,’T’,’E’,’F’,
    H’,’G’,’H’,’d’,
    g’,’G’,’G’,’g’,’t’,’f’,
    s’,’s’,’s’,’*’,’E’,’T’,’E’,’H’,
    H’,’A’,’H’,’*’,’E’,’T’,’E’,’H’,
    G’,’E’,’H’,’H’, ‘%’,’%’};
    intbb[ ]={8,8,8,6,2,
    8,6,2,8,8,
    8,8,8,6,2,
    8,6,2,16,
    8,6,2,8,6,2,
    2,2,4,4,2,8,6,2,
    2,2,4,4,2,8,6,2,
    8,6,2,16,
    8,6,2,8,6,2,
    2,2,4,4,2,8,6,2,
    2,2,4,4,2,8,6,2,
    8,6,2,16,
    64,64};
    // pin 8 ga dinamik ulansin
    intspeakerPin = 8;
    // nota, davrni hosil qilish jadalligi
    int tempo,notes,beats;
    // notani ijro etish amali
    void playNote(char note, int duration)
    {
    // ikki oktava oralig‘idagi notalar nomi uchun massiv
    charnames [ ]={‘c’,’r’,’d’,’s’,’e’,’f’,’t’,’g’,’u’,’a’,’b’,
    h’,’C’,’R’,’D’,’S’,’E’,’F’,’T’,’G’,’U’,’A’,’B’,’H’,’F’};
    // notalar chastotasining massivi
    inttones[ ] = {261,277,293,311,329,349,370,392,415,440,466,
    494, 523,554,587,622,659,698,740,784,830,880,932,988};
    // tegishli notaga tonini ierosi
    for (int i = 0; i < sizeof (tones); i++)
    {
    if (names[i] == note)
    {
    tone(speakerPin,tones[i],duration);
    }
    }
    }
    void setup()
    {
    pinMode(speakerPin, OUTPUT);
    tempo=50; // musiqa tovushini ijro etish tezligi
    }
    voidloop ()
    {
    for(int i=0;i
    {
    notes=melody[i];
    beats=bb[i];
    if (notes == '*')
    tone(speakerPin,0, beats*tempo); // sokinlik
    else
    playNote(notes, beats*tempo);
    // notalar о‘rtasidagi sukut
    delay(beats*tempo+tempo);
    }
    }

    Download 13,09 Kb.
    1   2   3   4




    Download 13,09 Kb.

    Bosh sahifa
    Aloqalar

        Bosh sahifa



    Pezonurlatgich. Pezonurlatgichni boshqarish: tonni o‘zgartirish, davomiligini o‘zgartirish Ishdan maqsad

    Download 13,09 Kb.