Go Down

Topic: midi footswitch - 12 in 5 out? (Read 764 times) previous topic - next topic

Nick Robinson

I'm an ardunio novice and after a few trial experiments, have the basics of input & output. I now want to build a specific midi controller for my echoplex digital pro looper. I have the midi output scripted and working, but I need to put together the inputs & led outputs for 12 switches and 5 indicator LEDs. Does the attached image seem a sensible approach? It would be nice to use fewer switch inputs, but not if this requires a lot of extra decoding script. I have to balance coding complexity with soldering complexity!

Am I correct in thinking I can use 5 analog pins for the led outputs?



All help gratefully appreciated!

MarkT

Yes you can use the analog pins as digital outs (they number 14 upto 19 in calls to digitalWrite())

You would save pins by having the switches in a matrix - it sounds like these are configuration switches (not just push-buttons) so the matrix would need a diode per switch (there are probably examples in the playground for doing this).  You are using D1 for a switch which will interfere with serial protocol for downloading sketches - move this to A0 perhaps?  If you do connect a switch to D1 (TX) then have a 1k series resistor to prevent burning out the pin when its being used as an output (the bootloader does this on reset).
[ I won't respond to messages, use the forum please ]

Nick Robinson


You would save pins by having the switches in a matrix - it sounds like these are configuration switches (not just push-buttons) so the matrix would need a diode per switch


No, they are just hon-latching push buttons - I need to send "long" signals (ie sustained footpress) some aspects of the looper respond differently depending on the length of the signal.

I've been reading about diodes in this manner, yet to find an example using the exact number I need - is there a generic approach to arranging into a matrix?

Thanks Mark....

Grumpy_Mike

Quote
is there a generic approach to arranging into a matrix?


Yes, it is a matrix with rows and columns as many of each as you need.
At each rows and columns intersection there is a switch and series diode.
You drive the rows high (output pins) and read the value from the columns (input pins). There is a pull down on each input so that if the switch is not pressed then that input looks like a zero, if it is pressed then it looks like a one on that column input when the appropriate row is driven high.
At any moment you know what row you are driving high so you know what switch each column corresponds to. Looking at each column for every row being put high in turn constitutes a scan of the matrix.

Look for my schematic here on an 8X8 http://www.thebox.myzen.co.uk/Hardware/Econo_Monome.html
or here for a 4X4 http://www.thebox.myzen.co.uk/Hardware/Mini_Monome.html

Nick Robinson

#4
Mar 11, 2011, 06:05 pm Last Edit: Mar 11, 2011, 07:20 pm by Nick Robinson Reason: 1
Am I correct in thinking that I don't need the diodes if only one switch were to be pressed at a given time?

So a 3x4 matrix would give me the 12 values I needed with only 7 digital pins used?

I've got switches working wiring them directly to pins at the moment. I'm using the button library

if(RECbutton.isPressed())
     {
     MIDI.sendNoteOn(38,127,1);  // record on
     while(RECbutton.isPressed()) // wait until switch is released
        {
        delay(10);  
        }      
     MIDI.sendNoteOn(38,0,1);  //  off
      }

which does what I need, but is prone to bounce errors. I'm struggling to see how to use the bounce library within the code - I would have thought (hoped!) there would be a library which includes debouncing within a button call, since you would always want isPressed to be debounced?

Could I use multiple calls, such as

if(RECbutton.isPressed())
    { 
     delay(10)
      if(RECbutton.isPressed())

etc??

It's frustrating - the system is doing what I want it to, but not *every* time ;(

Go Up