Stap 7: Arduino code
// Arduino to MIDI CC via OSC. // Arduino IDE 1.6.2. // Hens Zimmerman, June 8, 2015. #include <Ethernet.h> #include <EthernetUdp.h> #include <OSCMessage.h> #include <SPI.h> // MAC address from the bottom of the Ethernet shield. YMMV. byte Mac[] = {0x91, 0xB2, 0xDA, 0x0D, 0x32, 0xB0}; // An EthernetUDP instance to let us send packets over UDP. EthernetUDP Udp; void setup() { // DHCP assigns an IP address. Ethernet.begin(Mac); // We will only send here, so use an arbitrary listen port. Udp.begin(1234); } void loop() { // Create an OSC message. OSCMessage Msg("/analog/0"); // As a value, add the current value of analog 0 input. Msg.add(analogRead(0)); // Send to Max, [udpreceive 5678] listening to port 5678. // Change the IP address to the one of your computer running Max. Udp.beginPacket("192.168.178.42", 5678); Msg.send(Udp); // Clean up. Udp.endPacket(); Msg.empty(); // Give ADC (analog to digital converter) some time to settle down. delay(20); }