Using Leonardo midiusb library to switch relay BASIC question

HI everybody :wink:

I just bought a Leonardo to use it as a USB to MIDI "in" to switch some relays.
I ve been able to load a basic code that tells me my Leonardo works great and btw is already recognised by my apple MacBook Pro.
Could someone point me to some article or basic code that could help me .
I am generating a midi note "on" with my stream deck and I would like to be able to switch a relay . one different relay per note of course .
I bought a 4 relays card : JBtek-Channel-Module-Arduino.

basically note 60 will switch first relay. note 61 ... the other etc etc .I would like to be able to determine the "timing" as well (timing when the relay stay "on " )
I know it seems for all of you very easy to implement but I have to say... I am an absolute beginner :grinning: :grinning: :grinning:

thanks so much for your help

Phil

  1. Learn to recognise the noteOn. Have the onboard led go on, when you press one button on the Stream Deck. Make it blink once for note 60, twice for note 61...
  2. Learn to switch on and off any of the relays.

When you succeed with task 1 and 2 separately, combine them. If you have trouble with any of them, don't even think of writing a program which combines task 1 and 2 and the timing thing, thinking that would be a single task with a single solution.

Well, you have that Stream Deck. You describe what action will do the timing. If a noteOn event switches the relay on, should a noteOff event switch it off? Or a noteOn with velocity zero, which is commonly used. Or do you have a modulation wheel or twist knobs or sliders on the Stream Deck that send control change events? Should the Leonardo catch such events to adjust the timing?

I get it .
let me try that way :slight_smile:

right now when a button is pressed it generate a midi note "on" when pressed and a note off when released .
I choose channel 1 . with midimonitor I can see the the stream deck send the note to the Arduino I used that code to "test it " :

now I have the LED blinking when I press a button on stream deck .
sorry if it feel like a mess :slight_smile:
I would like now to remove part of the code I don't need and try to adapt it .
thanks for your help !
Phil

maybe I should ask help to write it from scratch for me :slight_smile: . is there a part of the forum when we can hire people for small task like that ? tx for your help !

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.