Arduino Play Despactio

Поділитися
Вставка
  • Опубліковано 15 вер 2024
  • Despacito playing on Arduino Piano
    i am not a Piano Artist, but i tried to learn it first then i played despacito on this hardware. it was little difficult but i hope you like my effort.
    Scroll down for code.....
    Please like & Subscribe for more videos
    Luis Fonsi -Despacito song
    • Luis Fonsi - Despacito...
    Download Max 7 software
    cycling74.com/...
    If you want to support my video please buy any product through my amazon affiliate link. I will receive a commission, at no extra cost to you.
    LIST OF COMPONENT (affiliate links)
    amzn.to/2fvSRJq (Arduino)
    amzn.to/2vmSK8l (Resistor)
    amzn.to/2wxPmWz (Breadboard)
    amzn.to/2vJ3lvo (Jumper wire)
    // drawMIDI
    int myKey[12];
    int myOldKey[12];
    int myNote[] = {79, 77, 76, 72, 74, 71, 69, 67, 65, 64, 62, 60};
    int keyPin[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};
    // Pins for MIDI keys
    // This is the value required to consider the key 'touched' and trigger a MIDI signal
    int touchedCutoff = 36;
    // This is the value required for the first part of goMIDI
    int midiInfo = 144;
    // This is the section that sets up serial communications
    void setup(){
    Serial.begin(19200); //if using hardward MIDI or HIDUINO, change to 31250
    //19200 baud, requires serial to MIDI conversion on your computer
    }
    // This is the section that reads the capacitance and determines what to do, noteOn or noteOff
    void loop(){
    // only send MIDI messages when something changes
    //instead of parenthesis () put angle bracket as UA-cam description does not allow angle bracket
    for (int i; i(12; i++) {
    myKey[i]=readCapacitivePin(keyPin[i]);
    if (myKey[i] ) touchedCutoff){
    myKey[i]=127;
    }
    else{
    myKey[i]=0;
    }
    if (myKey[i] != myOldKey[i]) {
    myOldKey[i] = myKey[i];
    goMidi(midiInfo, myNote[i], myKey[i]);
    }
    }
    }
    // The readCapacitivePin function is used to read whether the graphite strip connected to each pin is actually being pressed or not
    // this part of the code is based on an open example on the Arduino playground for 'Capacitive Sensing'
    // readCapacitivePin
    // Input: Arduino pin number
    // Output: A number, from 0 to 17 expressing
    // how much capacitance is on the pin
    // When you touch the pin, or whatever you have
    // attached to it, the number will get higher
    uint8_t readCapacitivePin(int pinToMeasure){
    volatile uint8_t* port;
    volatile uint8_t* ddr;
    volatile uint8_t* pin;
    byte bitmask;
    if ((pinToMeasure )= 0) && (pinToMeasure (= 7)){
    port = &PORTD;
    ddr = &DDRD;
    bitmask = 1 (( pinToMeasure;
    pin = &PIND;
    }
    if ((pinToMeasure ) 7) && (pinToMeasure (= 13)){
    port = &PORTB;
    ddr = &DDRB;
    bitmask = 1 (( (pinToMeasure - 8);
    pin = &PINB;
    }
    if ((pinToMeasure ) 13) && (pinToMeasure (= 19)){
    port = &PORTC;
    ddr = &DDRC;
    bitmask = 1 (( (pinToMeasure - 13);
    pin = &PINC;
    }
    // Discharge the pin first by setting it low and output
    *port &= ~(bitmask);
    *ddr |= bitmask;
    delay(1);
    *ddr &= ~(bitmask);
    int cycles = 16000;
    for(int i = 0; i ( cycles; i++){
    if (*pin & bitmask){
    cycles = i;
    break;
    }
    }
    *port &= ~(bitmask);
    *ddr |= bitmask;
    return cycles;
    }
    // This is the section that translates the touches into MIDI signals
    void goMidi(int cmd, int data1, int data2) {
    Serial.write(cmd); // set value stays the same
    Serial.write(data1); // note number, 60 or 49 or whatever
    Serial.write(data2); // velocity, keep at 127 for ON or 0 for OFF
    delay(2);
    }

КОМЕНТАРІ • 5

  • @yaseens7
    @yaseens7 5 років тому +1

    Omg 😮! This is the best video man! Love it. God bless you!

  • @yaseens7
    @yaseens7 5 років тому +2

    Watch the music in 2x speed.. it’s amazing 😉

  • @subhraZZ..04
    @subhraZZ..04 4 роки тому +1

    Sir where is the speaker??

  • @magneticballtoys2163
    @magneticballtoys2163 5 років тому

    Amazing bro
    please make a video of the piano apply to cans of coca cola or other beverage cans

  • @anjumshaikh5314
    @anjumshaikh5314 6 років тому

    Nice