damit es hier mal ein wenig weitergeht:
Habe einen MIDI-Controller auf Arduino Basis mit 4 mechanischen und einem optischen Encoder sowie 4 Pushbuttons aufgebaut.
Der Arduino ist bei mir ein Leonardo Pro-Micro welcher mit dem TeeOnArdu Add-on zum Midi-USB-Device gemacht werden kann. Des weiteren
ist das Teensyduino Arduino-Add-on nötig. Bei Verwendung eines Teensy kann auf das TeeOnArdu Add-on verzichtet werden da der Teensy
ab Werk, MIDI über USB beherscht. Zusätzlich habe ich die MIDI Elements Libary von Thomash Ghz installiert, diese erleichtert den Umgang mit MIDI erheblich.
Sind diese Voraussetzungen geschaffen ist es kein grosser Aufwand mehr einen funktionsfähigen Controller zu programmieren.
Ich habe für die Recherche und Beschaffung letztenendes mehr Zeit gebraucht als zum Aufbau des Controller.
Der Main VFO mit 600 P/R ist leider sehr empfindlich, da suche ich noch eine Möglichkeit das Verhalten ein wenig zu beruhigen.
Es gibt auch sicherlich noch Verbesserungspotential, da dies mein erstes Arduino/Programmier Projekt überhaupt ist.
Der MIDI-Controller ist unter Zeus Radio als auch unter PowerSDR verwendbar.
An dem Pro-Micro sind jetzt noch 4 Analoge Pins frei, da könnte man noch Potis anschliessen.
Da mir aber für ein 4x4 Keypad weitere 8 Digitale Pins fehlen, werde ich bei der nächsten Bestellung in China
einen Teensy ++2 ordern.
Code: Alles auswählen
// MIDI Elements
// by Tomash Ghz
// www.tomashg.com
// ghz.tomash@gmail.com
//
// MIDI-Controller to work with:
// ZEUS Radio https://www.hfrelectronics.com/zeus-radio
// and PowerSDR mRX PS v3.3.9.0 http://openhpsdr.org/download.php
// Sketch by DH1KLM
// InterruptPins on Leonardo Pro-Micro
// pin 0 is interrupt 2
// pin 1 is interrupt 3
// pin 2 is interrupt 1
// pin 3 is interrupt 0
// pin 7 is interrupt 4
#include <MIDIElements.h>
boolean debug=false; // print to serial instead of midi
boolean secondary=false; // enable secondary midi messages
int midiChannel=1; // midi channel number
int butPin1 = 10; // digital pin for reading first button
int butPin2 = 16; // digital pin for reading second button
int butPin3 = 14; // digital pin for reading third button
int butPin4 = 15; // digital pin for reading fourth button
// declare all your components here
MIDIEncoder *enc1; // Main Encoder 600 P/R should be mapped in SDR-Software as VFO A
MIDIEncoder *enc2; // Encoder can be mapped to whatever you want
MIDIEncoder *enc3; // Encoder can be mapped to whatever you want
MIDIEncoder *enc4; // Encoder can be mapped to whatever you want
MIDIEncoder *enc5; // Encoder can be mapped to whatever you want
Button but1(butPin1, midiChannel, 27, secondary, debug); // button 1 on pin 10
Button but2(butPin2, midiChannel, 28, secondary, debug); // button 2 on pin 16
Button but3(butPin3, midiChannel, 29, secondary, debug); // button 3 on pin 14
Button but4(butPin4, midiChannel, 30, secondary, debug); // button 4 on pin 15
void setup(){
enc1 = new MIDIEncoder(0,4,midiChannel,22,false,false); // setup an encoder on pins 0 and 4
enc2 = new MIDIEncoder(1,5,midiChannel,23,false,false); // setup an encoder on pins 1 and 5
enc3 = new MIDIEncoder(2,6,midiChannel,24,false,false); // setup an encoder on pins 2 and 6
enc4 = new MIDIEncoder(3,8,midiChannel,25,false,false); // setup an encoder on pins 3 and 8
enc5 = new MIDIEncoder(7,9,midiChannel,26,false,false); // setup an encoder on pins 7 and 9
usbMIDI.setHandleNoteOff(OnNoteOff); //set event handler for note off
usbMIDI.setHandleNoteOn(OnNoteOn); //set event handler for note on
usbMIDI.setHandleControlChange(OnControlChange); // set event handler for CC
}
void loop(){
// add here all the input component reads
enc1->read(); // read encoders and send midi messages
enc2->read();
enc3->read();
enc4->read();
enc5->read();
but1.read(); // read buttons and send midi messages
but2.read();
but3.read();
but4.read();
usbMIDI.read(); // read all the incoming midi messages
}
//====================================================================
// event handlers
void OnNoteOn(byte channel, byte note, byte velocity){
// add all your output component sets that will trigger with note ons
}
void OnNoteOff(byte channel, byte note, byte velocity){
// add all your output component sets that will trigger with note ons
}
void OnControlChange(byte channel, byte control, byte value){
// add all your output component sets that will trigger with cc
}
Und so sieht der Versuchsaufbau aus.
Verbesserungsvorschläge sind gerne Willkommen
https://www.arduino.cc/en/Main/Software
https://github.com/adafruit/TeeOnArdu nur für Arduino nötig. lässt sich über den Boardmanager der Arduino-IDE nachinstallieren.
https://www.pjrc.com/teensy/teensyduino.html Ist in jedem Fall nötig um MIDI über USB programmieren zu können.
https://github.com/ghztomash/MIDIElements erleichtert den Umgang mit den MIDI Befehlen, Encodern und Buttons.
73 de Sigi, DH1KLM