• Hi there,

    Im looking for some help with coding for a project im working on if some kind soul could help me with it, as i am new to coding and dont really know how to make it work. Its prob very easy to do for someone who knows what they are doing,

    Basically im trying to create a MIDI controller, although im having some difficulty coding the values to MIDI and sending it down the USB to MIDI converter. I have 2 pots and 2 switches to code. A kind friend give me the code for one of the pots although i cant seem to get it to work with the Espruino. The code is:

    function onInit() {
    
    Serial1.setup(31250, {tx:B6,rx:B7});
    
    Serial1.write(0x90);
    Serial1.write(0x3D);
    Serial1.write(0x00);
    Serial1.write(0x90);
    Serial1.write(0x3D);
    Serial1.write(0x44);
    }
    
    var Pot1=0;
    
    function getAcc() {
    
    var Pot1 = analogRead(C0);
    
    Pot1 = round(Pot1*128);
    
    Serial1.write(0x0B);
    Serial1.write(pot1);
    Serial1.write(0x9F);
    }
    
    onInit();
    setInterval(readPot1, 200);
    

    This code doesn't work for me for some reason- it keeps saying undefined. & I dont want to keep hassling my friend as he has helped me out loads to get to this point! Does someone know where i have gone wrong interpreting this code?

    The potentiometers are Linear btw.

    I have included a diagram of my wiring with my circuitry also to the Espruino.

    I know this will be useful
    http://www.midi.org/techspecs/midimessages.php

    If anyone could help me out with the switches or getting the pots working (Or both!) i would be soo greatful! How would i get this to work does anyone know? All i have to do is get the right code from the Voltage value to be turned to MIDI and then send down the MIDI to USB converter to the computer.

    [](http://IMG_1102.JPG)

    Thank you!

    Kind regards
    Connor

About