Programmable 8 Loops Pedal Switcher With Arduino Mega2560

48,631

72

186

Introduction: Programmable 8 Loops Pedal Switcher With Arduino Mega2560

last update: february 17 2016

This is the second part of my previous tutorial about how to do simple programable pedals switcher (or looper) now with a MEGA2560 Arduino to achieve 8 storable loops on 8 presets. I recommend to take it a view for the coding part explanation and how the things are tight together.

Note that is possible to improve the number of total loops. Just keep in mind that it add more lines to the code and more cost on hardware. That said, improving the possibilities in the mean time!

Number of max loops = total number of digital pins - 5 /3 (minus 3 pins for selecting mode and the two Rx/Tx)

In this tutorial we have 51 digital pins - 3 = 48 / 3 so 16 loops available. Just think you can add more interesting options like increasing the number of presets, add a display or read pot values for expression pedals by exemple, thus decreasing the number of available loops. But frankly: "who needs 16 pedals on a pedalboard?"

Sure, they are...

AVOID using analog pins named A0 to A15, just use the digital ones! (2 to 53) See the MEGA2560 pinout

Note: this project DOESN'T allow to reverse order of the pedals. This involves to matrix all that! That means: number of relays = (quantity of pedals) X (quantity of pedals)!!! and a lot of nightmares and disillusion! But actually you can consider 2 (or more) groups of loops, ie: one before the jack input of your amp and the other on the fx loop, if your amp is provided obviously! The only thing to do is to add a couple of chassis jack between two relays, the choice is yours. This is called the "breaking technique".

We can also use pin D1(Tx) for Midi communication.

So, in order to keep it as simple as wanted, see the schematic of this version of the project.

-----------------------------------------------------------------------

Caution: some noise issues where experienced by some
builders (me included). I suspect those cheap and chinese relays aren't made for audio signals. The ideal relays should be some called DPDT but for instance few advices can be followed: use shielded cables all along the signal path, ensure all the circuit in a metallic box use caps (usually 10u) for decoupling and/or add some high resistances to all in and outs jacks. Adding a booster pedal in front of the input may strongly reduce these noise...

______________________________________________________

Hardware:
-1 chinese Arduino Mega 2560 (keep your original for test other projects)

-8 momentary switches

-1 LM7805 regulator (5v.)

-1 three ways selector

-8 5v. DPDT relay modules or

-1 sixteen relays module (9 / 12 volts) or 1 eight dpdt relay bord (it's a lot expensiver)

-18 chassis 6.3 female jack (minimum) / 20 if you want to add the "breaking technique"

-1 9V-12v /3A power supply

-16 leds and 470 ohms resistors

-1 MIDI din + 1 220 ohms resistor (for optional MIDI out)

-spare cable or chinese Dupont wire (male to female)

(not included: the box)

______________________________________________________

Tools:

-plyers/ cutter

-soldering station/ iron

______________________________________________________

USE:

-position "A" from the selector (cases a,b,c,d,e,f,g,h on the sketch) -> select wich pedal to loop ON (1,2... 8)

-position "B" (cases i,j,k,l,m,n,o,p) -> select the number of the preset (1 to 8) where you want to preserve the loops (the led of the preset you choose will lit 2 or 3 times)

-position "C" (cases q,r,s,t,u,v,w,x)-> read the preset (1 to 8) you stored previously

Watch it on youtube

______________________________________________________

needed Arduino library:

keypad.h

Step 1: Programmable MEGA2560 Arduino Based 8 Pedals Looper

You can even add some pot reading for expression pedals: there's enough room for it! Or even 8 more leds that can indicate wich effect loop is engaged when in "read" mode (in parallel to relays). Some follower suggested me to implement the possibility to select in wich "pre" or "post preamp" mode each effect can be selected (google for "4 cables" technique). This is also possible but adding a 16 relays module that will take more space and weight on the box. I suggest choosing "16 x DPDT relay module" to limit space waste but I must admit that I didn't found any cheap of these (~100$/piece) !

For this simple project, I suggest you to buy a cheap chinese copy of this board as you can find it for ~7$. You'll save your original board for arduino practicing.

So, here is the code for this beast as an example (choose your own pins):

Many thanx to PascalP3 to have corrected and improved this sketch!

Step 2: Hardware Building

Here's an example with 5 switches and 1 function selector and another 8 loops project by David B1 who gently share pictures of his great job! Thanks to him.

-------------------------------------------------------------------------------------------------------

check out some outstanding bands I play with

ZeK

7 People Made This Project!

Recommendations

  • The 1000th Contest

    The 1000th Contest
  • Battery Powered Contest

    Battery Powered Contest
  • Hand Tools Only Challenge

    Hand Tools Only Challenge

186 Discussions

0
aAnjiNn
aAnjiNn

3 years ago

Can I create infinite patches for the 8 pedal loops? How would I do that? Thanks!

0
CarraN
CarraN

Reply 3 years ago

hey!

what do you mean about infinite patches?

0
aAnjiNn
aAnjiNn

Reply 3 years ago

I'm sorry, I mean "presets"! For example, in a gig I have 30 songs, each one with different pedal combinations, can I have 30 presets for each song?

Many thanks!

0
CarraN
CarraN

Reply 3 years ago

30 x 30 = 900 memory presets in a MEGA2560?


The eeprom has 4kB, so 4000 /8 = 500.
Sadly, it'll miss 400 places of presets the way memory is managed in this project...
One solution could be to write the eight relays states in a bit, by ex:
00010010, 11101100, etc... But I must admit that 's something that I've not achieved, though I KNOW it's possible. In this case you could have 4000 memory preset.
Other one is adding more memory to the Arduino. There are plenty of tutorials out there.


cheers

ps:If you find the solution you're welcome to share

0
JonathanK154
JonathanK154

Reply 10 months ago

I know it's 2 years late, but you asked for a shared solution ;-)
I made a version as you described with storing the preset as one byte. With bitRead you can iterate over all 8 bits of a byte and you will end up having all your relay states.

Something like:
void byteToRelayStates(byte b) {
for (byte i = 0; i < 8; i++) {
int bitValue = bitRead(b, 8-(i+1));
relay[i] = bitValue == 1;
}
}

0
CarraN
CarraN

Reply 10 months ago

Hey, why not to share the whole code ? Because is not clear how to implement these few lines into the rest of the sketch. If you don't want it's ok, it's up to you!

cheers

0
JonathanK154
JonathanK154

Reply 10 months ago

Hey, I definitely will do so. But I want to do some clean up as the current version is a little bit messy and needs some polish ;-)
I am a professional developer but new to Arduino and C and the IDE. I still want to raise the code quality to my personal desired level.

0
CarraN
CarraN

Reply 10 months ago

Sure I understand ! So can you please explain (to us) this line code I don't got it:

relay[i] = bitValue == 1;

The rest is just Arduino's standard code, so ... Thanks though !

cheers

0
JonathanK154
JonathanK154

Reply 10 months ago

Sure. I store all the states for the relays in an internal Boolean array before switching.
So while iterating over the Bits, I check of the value is 1. The result of (bitValue == 1) is bool an will be stored at the position of the relay.

So relay is of type bool[8].

You can write it longer as:

if (bitValue == 1) {
relay[I] = true;
} else {
relay[I] = false;
}

0
CarraN
CarraN

Reply 10 months ago

OK so if I understand well :

relay[i] = bitValue == 1;

equals:

if (bitValue == 1) {
relay[I] = true;
} else {
relay[I] = false;
}
This manner I (with my poor self-education on coding arduino) understand lot better! though it involves more text...

thank you Master!
0
JonathanK154
JonathanK154

Reply 10 months ago

Yes, this is exactly the same. Whenever you assign a variable with true or false based on a condition, you can just assign this condition to the variable directly.
In more complex: The part in the parantheses after if is just a boolean value which will checked if true or false.
So when you do something like if ([condition which is `true`]) var = true; it will be the same when you write var = [condition which is `true`];

0
CarraN
CarraN

Reply 10 months ago


so in this exemple:
bitValue ==1 is condition which is `true`

OK, I learned something. Good!

0
CarraN
CarraN

Reply 10 months ago

Nice ! plenty more memory available in there !
I'll try your code these coming days though I dont really need that extra memory but for the sake of this instructable! Thank you man!

cheers

0
wickay1979
wickay1979

11 months ago

may ask you about the midi connection?

0
CarraN
CarraN

Reply 11 months ago

sure, what do you want to know?

0
wickay1979
wickay1979

Reply 11 months ago

do u have schematic or layout for the midi connection betwen arduino,relay,and midi socket, if want to use the midi connection for program change, how can i edit the midi program,as we know,there is midi section in the ino file..thank you so much i apreciated

0
wickay1979
wickay1979

Reply 11 months ago

Nice...Thank you so much...🀘🏻☺️🀘🏻

0
CarraN
CarraN

Reply 11 months ago

you're welcome!

0
Eltonrd
Eltonrd

1 year ago

Hello! first thanks so much for sharing this! greetings from Brazil!
I have a newbie doubt. In the list of materials were listed 9 / 12v relays. but in the images I am seeing the 5v connections.
I will buy DPDT relays! should i buy 5v or 12v?
thank you very much.