Hello and thanks for reading.
I'm new to coding, but have been lurking here for about 5 months and have built a large midi controller using the control surface library.
Now I am trying to create a simple wireless usb midi controller. I have successfully built this project:
which is exactly what I want, but it is designed for 1 potentiometer sending a midi cc message.
I want to adapt this code to read 4 momentary buttons and send independent usbMidi note on/off messages for each. I'm really not sure on the best way to implement this and would appreciate any advice.
specifically:
-should I bounce buttons in node code
-I guess i need to enable digital pins and pullup resistors
-How should I get the uart.available on the base to differentiate between the 4 buttons on the node?
I'm using 2 teensy 2.0, and 2 XBEE series 3 pro configured as series 1 in transparent mode.
Thanks!
(This is my first post, I hope this is the correct way to share code.)
base code (wireless receiver plugged into computer for midi control of ableton or other daw):
#include <SoftwareSerial.h>
byte data;
HardwareSerial Uart = HardwareSerial();
void setup() {
Uart.begin(9600);
pinMode(11, OUTPUT);
}
void loop() {
if(Uart.available() > 0) {
data = Uart.read();
delay(1);
usbMIDI.sendControlChange(1, data / 2, 1);
}
}
Node code (wireless transmitter connected to a pot on analog 0):
#include <SoftwareSerial.h>
byte previous;
byte data;
HardwareSerial Uart = HardwareSerial();
void setup() {
Uart.begin(9600);
}
void loop() {
data = analogRead(0) / 4;
if(data != previous) {
previous = data;
Uart.write(data);
delay(10);
}
}
xbee_base.ino (283 Bytes)
xbee_node.ino (284 Bytes)