Discussion (*ask your questions here!) > Questions

MidiSprout controlling 8channel Switch Relay


Hi Sam,

I'm preparing an art installation with the MidiSprout builded with your tutorials,
My idea is to now change the MIDI output jack of my midi sprout (I do not need midi notes), what I need is something simpler, I want to control in some way an 8-channel relays switch module (the ones that often used with arduino).

at the moment I am controlling the relays with a simple random generator written in an Arduino Uno. the connection and circuit of the relays work very well.

My question is: how could I make the plant define those parameters on and off in the 8 channel relays module? that is: (1) which relay channel it selects and (2) how long that channel remains on, before it is disconnected again.

thanks a lot in advance!

Hello Julio, yes that is a great idea to control a set of relays with the sprout.  How much programming experience do you have, and is this your first electronics project?  Your modifications are very doable, but it will take a bit of solder and code!

1.) what type of relay board are you using?  Many relay boards for arduino have 8 individual digital input pins, some use SPI/I2C, and others can use Serial to trigger the relays.   I think we have 8 digital pins available on the sprout, so even the most basic or diy relay setup should be able to be 'wired' to the sprout.

2.) You can easily modify the code to turn a relay on when a note is triggered and off when an note is updated. 
   a. First you should increase the note polyphony from 5 to 8 (to match your relays). 
   b. Second, In setNote() add  some code to turn on the relay digitalWrite(relayPin[ i ],HIGH);  where relayPin[] is an array containing the pin number for each of the relay inputs and "i" is the currently available 'note' of the 8 available from polyphony
   c. Third, in checkNote() add some code to turn off the relay when the note is expired digitalWrite(relayPin[ i ],LOW);

This method will have the relays mirror the notes and durations as they turn on and off.

Good luck!  please post some more info of your build!



[0] Message Index

Go to full version