Can I use an arduino mini to make a simple midi controller?

Bricksnbeatles

Member known well
@Bricksnbeatles What type of MIDI port did you plan on using?
Either panel mount DIN or TRS— since it’s going to a device with another DIN port, it would likely be beneficial to have it be DIN on both sides of the cable so if it craps out while away from home, and music store would have a replacement cable available for sale. On the other hand, DIN is bulky, and the space savings on a board by replacing one of the DIN connectors with a right angle TRS plug would be huge, plus it’s easy enough to wire up some DIN/TRS cables, and just take spares with me wherever I bring the board.
 

PedalPCB

Admin (Robert)
Staff member
I've had a simple little MIDI project in mind for a while, just something for my own use.

The hardware wouldn't be a whole lot different from what you need here. :unsure:


The most commonly used connectors are 1/8", 1/4", and 5-pin DIN, right?
 

Bricksnbeatles

Member known well
I've had a simple little MIDI project in mind for a while, just something for my own use.

The hardware wouldn't be a whole lot different from what you need here. :unsure:


The most commonly used connectors are 1/8", 1/4", and 5-pin DIN, right?
Yup, as well as USB (usually type B), which is actually probably *the* most common type when you look beyond just guitar stuff (probably half of the keyboard midi controllers on the market these days don’t even have a DIN port, just USB-B)

What kind of stuff are you looking to use midi for in your rig?
 

giovanni

Well-known member
I'm putting together a little set of helper classes to make writing code for basic pedal related activities a little quicker and easier. I have classes for switches, LEDs, relays, and IO pins.

For example, the switch class has built in debouncing and can detect short and long presses. It handles all of the underlying hardware calls (data direction register, enabling/disabling pullup resistor, etc).

Since I write AVR code so rarely I find myself always having to go back and reference my old code to refresh my memory on pin/port/bit operations. This allows me to work with a much more intuitive set of functions and put something together in just a few seconds.

Right now I'm focusing on AVR but I'll be putting together an Arduino version as well. It's really nothing you can't find elsewhere, especially in the Arduino libraries, but this puts everything I commonly use together in a nice simple little package.

For example:
Code:
// Configure Footswitch on Pin 3 (PB4)
Button footswitch(IOPin(&PORTB, PB4, &PINB, PINB4, &DDRB));

// Configure LED on Pin 2 (PB3)
LED led(IOPin(&PORTB, PB0, &PINB, PINB0, &DDRB));

// Configure Relay on Pin 7 (PB2), Default to Open, Do not invert coil polarity
Relay relay(IOPin(&PORTB, PB2, &PINB, PINB2, &DDRB), OPEN, FALSE);

while (1)
{
    footswitch.Update();
   
    if (footswitch.OnPress())
    {
        led.Toggle();
        relay.Toggle();
    }   
}

Instead of:

Code:
DDRB &= ~(1 << PB4);    // INPUT - Footswitch
PORTB |= (1 << PB4);    // Enable pull-up resistor

DDRB |= (1 << PB3);    // OUTPUT - LED
DDRB |= (1 << PB2);    // OUTPUT - Relay

uint8_t lastState;
uint8_t currentState;

while (1)
{
    currentState = (PINB & (1 << PINB4));

    if ((!currentState) && (lastState))
    {
        lastState = currentState;
        PORTB ^= (1 << PB3);    // Toggle LED
        PORTB ^= (1 << PB2);    // Toggle Relay
    }
}
Nice.
 
Top