The BIG Arduino MIDI controller thread - Page 14
Page 14 of 16 FirstFirst ... 410111213141516 LastLast
Results 131 to 140 of 155
  1. #131
    Tech Mentor
    Join Date
    Sep 2013
    Posts
    159

    Default

    Hi All, I've been a little bit slack, sorry for not posting!!!

    Here's the code for my megafighter, 32buttons, 16 faders/knobs, support for rotary encoders, user programmable addressable rgb LEDs and saving to eeprom. It uses a mega2560 and the dual moco-lufa firmware (usb-serial and usb-midi) and the adafruit neopixel library.

    It's on my github repo, the original code is almost non-existent now but it did originally come from the arduino midifighter instructable as it's all written on arduino ide with arduino libs etc. the original code is open source, by extension so is mine, a mention in your code if you do adapt it would be nice, enjoy it and don't blame me if it breaks anything (it shouldn't break anything, I've been using it for some time now). I make no apologies for my coding style, or over/under commenting, it is what it is and it works for me. I haven't done a schematic, it's pretty simple to work out which pins you should attach to buttons and faders, if your faders appear noisy, you probably need to move the shared gnd to another gnd pin on the mega 2560, if that doesn't solve it, you'll need to look into solving the noise issue yourself, this is afterall a WIP and prototype code.

    https://github.com/Reggi3/megafighter

    I will add my precision pitch fader code sometime over the next couple of days or so.

  2. #132
    Newbie
    Join Date
    Jun 2014
    Location
    México city
    Posts
    3

    Default Some help needed.

    Hi, i got an issue... a little strange.

    I am using PWM to drive a couple of leds with the CC messages from the host (traktor) to represent the signal levels from decks a & b, at some point in the future i will use this signal to drive a line of leds using the lm3916 chip, i am using outputs 10 & 13 on the Leonardo Board since both use the same pwm frequency and i will need that.

    When the pin 10 is used nothing happens but when the pin 13 drives the led random noise get on the analog reads. not too much but is constantly sending messages.

    As you know pin 13 has it's own led on board and if a disconnect the "external" led everything work fine, so i'm pretty sure it's a hardware thing, ¿someone can help please?

    I'm using 8 analog ins, 10 digital and the 2 PWM outputs.

    This is the wire diagram:
    Attachment 23328

    And the code:




    /*
    Arduino*Leonardo*midi*controller.

    Based*on*the*ARCORE*work*from*Rkistner*to*send*and *get*midi*trough*the*board*usb*conection.
    ARCORE*is*working*with*Arduino*Leonardo,*Arduino*M icro*y*Bare*Conductive*Touch*Board*all*of*them*bas ed*on*atmega32u4.


    */

    //CC*outputs*from*the*host*to*drive*leds*can*be*on*a ny*channel*but*CC*must*be*10*and*13.

    //*Leds

    *int VUmetA=13; // Vu metter a
    *int VUmetB=10; // Vu metter b
    *float logcurve=10; // Adjust the log curve can work with fractions.
    *float x; // Used to float math.
    *
    //*Encoder

    *int EncPinA = 0;
    *int EncPinB = 1;
    *int PinALast = LOW; // last pin a value
    *int a = LOW;
    *int b = LOW;
    *
    //*variables*y*arreglos*para*la*lectura*digital

    *int Din[8] = {2, 3, 5, 7, 8, 9, 11, 12}; // Digital in array
    *int offsetD = 64; // Note offset
    *int LDin[8]; // Last digital values array
    *int DtempRead; // Temp digital read
    *int Chan = 4; // General MIDI channel
    *
    *// variables y arreglos para la lectura analoga
    *
    *int Ain[8] = {A0, A1, A2, A3, A4, A5, A6, A7}; // Analog array
    *int offsetA = 17; // CC Offset
    *int LAin[8]; // Last analog values array
    *int AtempRead; // Temp analog read
    *int thresh = 4; // To reduce the noise from pots

    //*----------------arcore*setup------------------

    void CC(byte channel, byte ccnumb, byte value) {
    ****MIDIEvent*CC*=*{0x0B,*0xB0*|*channel,*ccnumb,* value};
    ****MIDIUSB.write(CC);
    *}**
    *
    *void NOn(byte channel, byte pitch, byte velocity) {
    ****MIDIEvent*NOn*=*{0x09,*0x90*|*channel,*pitch,* velocity};
    ****MIDIUSB.write(NOn);
    }

    void NOff(byte channel, byte pitch, byte velocity) {
    ****MIDIEvent*NOff*=*{0x08,*0x80*|*channel,*pitch, *velocity};
    ****MIDIUSB.write(NOff);
    }
    *
    *//--------------------------------------------------------------------------------------------
    void setup() {
    **
    ****// setup encoder
    ***pinMode (EncPinA,INPUT);
    ***pinMode (EncPinB,INPUT);
    ***digitalWrite (EncPinA, HIGH);
    ***digitalWrite (EncPinB, HIGH);
    ***
    ****// setup digital
    ***for (int i=0; i<8; i++)
    ****{
    ******pinMode (Din[i], INPUT);
    ******digitalWrite (Din[i], HIGH);
    ****}// setup digital end
    ****
    }

    //----------------------------------------------------------------------------------------------
    *
    void loop() {
    //----------------------------------------------------------------------------------------------

    **//Read CC messages and send to pins 10 and 13 using pwm.
    *****
    ******if(MIDIUSB.available() > 0) {
    **********MIDIEvent*e;
    **********e*=*MIDIUSB.read();
    **********if(e.type == 0x0B && e.m2 == 10) { // detect CC 10 from host on any channel
    ***************x*=*e.m3;
    ***************x*=*(pow((x/127),*logcurve)*x);***// convert linear values to logaritmics.
    ***************analogWrite(VUmetB, (x*2));
    **********}
    *****************
    **********if(e.type == 0x0B && e.m2 == 13) { // detect CC 13 from host on any channel
    ***************x*=*e.m3;
    ***************x*=*(pow((x/127),*logcurve)*x);***// convert linear values to logaritmics.
    ***************analogWrite(VUmetA, (x*2));
    **********}
    }

    **//-------------------------------------------------------------------------------------------
    **
    **// Encoder
    *
    ******a*=*digitalRead(EncPinA); // Read a & b
    ******b*=*digitalRead(EncPinB);
    ***
    **********if (a != PinALast) { // test if "a" has changed from last state
    **********if(a == b) { // compare "a" & "b" if it's equal:
    ***************CC(Chan,*16,*127);**// send 127 to CC 16 of general channel defined before.
    ***********}****
    ***********else { // if it's not equal:
    ***************CC(Chan,*16,*1);****// send 1 to CC 16 of general channel defined before.
    ***********}
    *******PinALast*=*a;***************// define "a" last value
    }

    **//-------------------------------------------------------------------------------------------
    **
    **// Digital in. All internal pullup resistors has been called so a LOW state equals a Note On message
    **
    ***for (int i=0; i<8; i++)
    ****{
    ******DtempRead*=*digitalRead(Din[i]);
    ******if (DtempRead != LDin[i]) { // If temp has changed from last state
    ********if (DtempRead == LOW) { // and it's (LOW):
    **********NOn(Chan,*i+offsetD,*100);****// send Note On
    ********}
    ********else {
    **********NOff(Chan,*i+offsetD,*0);*****// if it's high send note off
    ********}*
    ********LDin[i]*=*DtempRead;************// Last value record on the array
    ******}
    ****
    ****}
    **//--------------------------------------------------------------------------------------------
    **
    ***// Analog in
    ***
    ***for (int i=0; i<8; i++)
    ****{
    ******AtempRead*=*analogRead(Ain[i]); // Read Analog Value
    ******
    ******if (AtempRead > LAin[i] + thresh || AtempRead < LAin[i] - thresh) { // if it is greater or lower from a range setted with the treshold value
    ************************************************** *************************
    **********CC(Chan,*i+offsetA,*AtempRead/8);********// send CC
    **********LAin[i]*=*AtempRead;*********************// Last value record on the array
    *********
    ********}*
    ******}***
    ****
    *//----------------------------------------------------------------------------------------------
    **
    **}//end void loop

  3. #133
    Tech Mentor
    Join Date
    Oct 2012
    Posts
    160

    Default

    Increase your thresh variable to 8.
    Shantea Controls - Custom MIDI controllers: Official | Youtube | Instagram | Tindie
    DJ Mixes: Psychill, Psydub, Dub | House, Progressive, Techno | Dubstep

  4. #134
    Newbie
    Join Date
    Jun 2014
    Location
    México city
    Posts
    3

    Default

    Quote Originally Posted by paradajz View Post
    Increase your thresh variable to 8.

    Thank you but it seems to be a hardware thing, i just add a 100 Ω resistor in series with the led on pin 13 and the noise disappear it dimm the led a little bit but it works, if i disable the cc midi signal from the host or set the code to digitalWrite instead analogWrite everything works fine too, also it only happens with analogWrite on pin 13.

    I know pin 13 have a onboard resistor but i can't test at the moment with another Leonardo board to check if my Leonardo fail in some way.

    Thank you anyway my friend, i will post if i can detect what is happening.

  5. #135
    Tech Mentor
    Join Date
    Oct 2012
    Posts
    160

    Default

    Try to use separate wires for your potentiometers and LEDs power supply.
    Shantea Controls - Custom MIDI controllers: Official | Youtube | Instagram | Tindie
    DJ Mixes: Psychill, Psydub, Dub | House, Progressive, Techno | Dubstep

  6. #136
    Tech Convert
    Join Date
    Nov 2013
    Posts
    8

    Default Arduino potentiometers and chroma caps

    Hello, I don't know if it has been asked before, but do any of you know if potentiometers sold by Arduino fit qith chroma caps ?

    Here is the product : http://store.arduino.cc/product/C000031

  7. #137
    DJTT Mapping Ninja Moderator Stewe's Avatar
    Join Date
    Aug 2010
    Location
    MIDI
    Posts
    7,492

    Default

    Quote Originally Posted by Aken View Post
    Hello, I don't know if it has been asked before, but do any of you know if potentiometers sold by Arduino fit qith chroma caps ?

    Here is the product : http://store.arduino.cc/product/C000031
    Unfortunately they are not. Chroma Caps can fit only at "D" shaped shafts. Ensure to grab correct ones in order to mount some chroma caps


  8. #138
    Tech Convert
    Join Date
    Nov 2013
    Posts
    8

    Default

    Thanks a lot Stewe

  9. #139
    Mudo
    Guest

    Default

    Is midi din port comunication implemented?

  10. #140
    Newbie
    Join Date
    Nov 2015
    Posts
    2

    Default

    One of my friend built a clone of a midi fighter out of an Arduino.
    Actually it was not too hard to pull off. His project has no LEDs on it though and he ran out of digital pins and didn't want to mess with a multiplexer.
    Also the hardware side of it was pretty straightforward.
    Programing it wasn't too bad, but I had to refer to a lot of example code to get it right.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •