electronics

esp mesh network with osc

With the painlessMesh library it turned out easy to set up a decentralised mesh network for a few ESP8266 modules. The example below show how I set it up and how to send and receive OpenSoundControl (OSC) messages. The code also work on an ESP32.

1. Install the painlessMesh and the OSC libraries for Arduino.

2. Program a few nodes (ESP8266) so that they all run this code...

//req. libraries: OSC, painlessMesh

#include <Arduino.h>
#include <painlessMesh.h>
#include <WiFiUdp.h>
#include <OSCMessage.h>
#include <OSCData.h>

#define MESH_NAME "networkname" //EDIT mesh name
#define MESH_PASS "networkpass" //EDIT password
#define MAX_CONN 4 //EDIT esp32 can have more than esp8266

#define INPORT 19998 //osc in port
#define OUTPORT 57120 //osc out port (sc)

IPAddress outIP;
WiFiUDP Udp;
painlessMesh mesh;

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  mesh.init(MESH_NAME, MESH_PASS, 5555, WIFI_AP_STA, 1, 0, MAX_CONN);
  Udp.begin(INPORT);
}

void pingFunc(OSCMessage &inMsg) {
  digitalWrite(LED_BUILTIN, 1 - digitalRead(LED_BUILTIN));  //toggle led
  OSCMessage outmsg("/pong");
  outmsg.add(mesh.getNodeId()); //uint32
  IPAddress ip;
  ip= mesh.getStationIP(); //0.0.0.0 if current base station
  outmsg.add(ip[0]);
  outmsg.add(ip[1]);
  outmsg.add(ip[2]);
  outmsg.add(ip[3]);
  ip= mesh.getAPIP();
  outmsg.add(ip[0]);
  outmsg.add(ip[1]);
  outmsg.add(ip[2]);
  outmsg.add(ip[3]);
  Udp.beginPacket(outIP, OUTPORT);
  outmsg.send(Udp);
  Udp.endPacket();
}

void loop() {
  mesh.update();

  int packetSize= Udp.parsePacket();
  if (packetSize) {
    OSCMessage inMsg;
    while (packetSize--) {
      inMsg.fill(Udp.read());
    }
    if (!inMsg.hasError()) {
      outIP= Udp.remoteIP();
      inMsg.dispatch("/ping", pingFunc);
    }
  }
}

3. After that power up the nodes and a new WiFi network should show up.

4. Connect a laptop to the new mesh network and take note of the IP number assigned.

5. Run the test code below on the laptop. It will broadcast a \ping OSC message and listen for \pong replies.

The test code is for SuperCollider but any program that can send OSC should work.

(
OSCFunc({|msg| msg.postln}, \pong);
NetAddr.broadcastFlag= true;
NetAddr("10.214.190.255", 19998).sendMsg(\ping);  //EDIT laptop ip number but leave 255 as the last number
)

The painlessMesh library will for sure come in handy when I need a network without a WiFi router, or for when trying to cover a larger area.
A major drawback though seem to be that the maximum number of nodes that can be used is really low. Apparently an ESP8266 can only handle 5 (TCP/IP) connections at the same time and an ESP32 about three times that. And that is not very many.

midi pedals

Here's how I built a USB foot pedal that sends out MIDI CC messages as well as note on/off messages when crossing some threshold.

To get a rugged pedal I bought a sewing machine foot pedal / speed control. For converting to MIDI and connecting to a computer i used a Digispark module. The two other parts needed was a 3,5mm socket and a 4K7 resistor.

pedal01

pedal00

The code for the Digispark is really simple and I programmed it from the Arduino IDE. THRESH_HI and THRESH_LO together with the state variable implements hysteresis, and lastVal is used to filter out any repeating values.

//with Digispark (Default - 16.5mhz)
//connect 4.7K resistor between tip and 5v, tip to P2 and sleeve to gnd

//usb yellow or red     5v
//usb white             data-
//usb green             data+
//usb grey or black     gnd

#define USB_CFG_DEVICE_NAME     'm','i','d','i','P','e','d','a','l'
#define USB_CFG_DEVICE_NAME_LEN 9
#include <DigiMIDI.h>

#define PINLED 1      //onboard led
#define PINSENSOR A1  //foot controller sensor (P2)
#define PINGND 0      //ground
#define CTRL 7        //midi controller (cc)
#define NOTE 99       //midi note
#define VELO 64       //midi velocity
#define CHAN 9        //midi channel
#define THRESH_HI 100 //0-127
#define THRESH_LO 50  //0-127

DigiMIDIDevice midi;
int lastVal = 0;
int state = 0;

void setup() {
  pinMode(PINLED, OUTPUT);
  pinMode(PINGND, OUTPUT);
  digitalWrite(PINGND, LOW);
  midi.sendNoteOff(NOTE, VELO, CHAN);
}

void loop() {
  midi.update();
  int val = analogRead(PINSENSOR);
  val = constrain(val, 9, 900);
  val = map(val, 9, 900, 127, 0);
  if (val != lastVal) {
    midi.sendControlChange(CTRL, val, CHAN);
    if (state == 0 && val > THRESH_HI) {
      midi.sendNoteOn(NOTE, VELO, CHAN);
      digitalWrite(PINLED, HIGH);
      state = 1;
    } else {
      if (state == 1 && val < THRESH_LO) {
        midi.sendNoteOff(NOTE, VELO, CHAN);
        digitalWrite(PINLED, LOW);
        state = 0;
      }
    }
    lastVal = val;
  }
  midi.delay(100);
}

Some SuperCollider test code...

MIDIClient.init;
MIDIIn.connectAll;
MIDIdef.cc(\pedalCont, {|...args| [\pedalCont, args].postln}, 7, 8);
MIDIdef.noteOn(\pedalOn, {|...args| [\pedalOn, args].postln}, 99);
MIDIdef.noteOff(\pedalOff, {|...args| [\pedalOff, args].postln}, 99);

MIDIdef.trace;

For another project I also made a 3D printed variant. This one is not so rugged and only acts as an on/off switch. It's based on Adafruit's USB_Foot_Switch_Controller but modified to fit a Digispark.

pedal02

Arduino code for this discrete pedal (only note on/off)...

//with Digispark (Default - 16.5mhz)
//modified Adafruit's USB_Foot_Switch_Controller

#define USB_CFG_DEVICE_NAME     'm','i','d','i','P','e','d','a','l'
#define USB_CFG_DEVICE_NAME_LEN 9
#include <DigiMIDI.h>

#define PINLED 1  //onboard led
#define PINSENSOR 2 //switch
#define NOTE 89  //midi note
#define VELO 64  //midi velocity
#define CHAN 9  //midi channel

DigiMIDIDevice midi;

int state = 0;

void setup() {
  pinMode(PINSENSOR, INPUT_PULLUP);
  pinMode(PINLED, OUTPUT);
  midi.sendNoteOff(NOTE, VELO, CHAN);
}

void loop() {
  midi.update();

  if (digitalRead(PINSENSOR) == 0) {
    if (state == 0) {
      digitalWrite(PINLED, HIGH);
      midi.sendNoteOn(NOTE, VELO, CHAN);
      state = 1;
    }
  } else {
    if (state == 1) {
      digitalWrite(PINLED, LOW);
      midi.sendNoteOff(NOTE, VELO, CHAN);
      state = 0;
    }
  }
  midi.delay(100);
}

openbci wifi shield diy

Here is how I built my own WiFi shield for the OpenBCI Cyton and Ganglion boards. The total cost was less than €10.

See the schematics.

* 1 ESP8266-12 module
* 1 ESP8266-12 adapter
* 2 push buttons
* 3 blue leds
* 1 NCP1117 voltage regulator
* 1 JST connector
* some resistors and capacitors
* pin headers and a piece of veroboard

On the white adapter board I first removed the 0K resistor link in the middle (R2). Then I cut the two tracks that run from VCC to the left hand side 10K resistor (R3). Next I soldered on a NCP1117 on the back side (not visible in the photo) and finally added two 100nF caps.

Last I mounted the ESP+adapter on a vero board, added male pin headers and the other components and wires.

IMG_20180626_160641

IMG_20180626_160755

It looks very rough but works great. Here are instructions on how to upload firmware and how to use it.

bluetooth module repair

This documents a repair of a Cyton board. The board would turn on and kind of work but one couldn't upload new firmware to it.

I localised the issue to the RFD22301 (aka RFDuino) module. To desolder it from the board I used some rose's metal - a material with low melting temperature (94°c) - and then put on new temporary pins to a few pads and put it on a breadboard.

IMG_20180607_153919

The module sort of worked but it still wouldn't be programmed. After lifting the metal shield and checking all the connections, I found a broken trace from the chip out to the rf_rxd pad (gpio0/aref) on the module. Tracing the fault a bit further it turned out to be a broken via. I tried to refill the via with solder but it was just too small to repair. So I ended up adding a thin copper wire directly from the pin to the pad and wrapped it in some kapton tape for isolation.

IMG_20180608_070749

I had to cut out a slot in the metal shield so that my wire could get out without getting squeezed and shorting to ground. It doesn't look pretty, but the module now worked and I could finally upload new firmware. And after soldering the shield back and putting back the module, the Cyton board worked again.

IMG_20180608_081319

I also repaired a broken trace on one of the serial lines. It's visible on the right hand side in the photo.

radarsensor

Last year I built this very simple motion detection device. It will trigger a noteOn MIDI message when someone enters a room, and a noteOff message when there's no activity. It's using a RCWL-0516 radar sensor and a Digispark clone (basically a ATtiny85).

radarsensor

//with Digispark (Default - 16.5mhz)
//RCWL-0516 Microw. Radar-ModulRCWL-0516

#define USB_CFG_DEVICE_NAME     'm','i','d','i','R','a','d','a','r'
#define USB_CFG_DEVICE_NAME_LEN 9
#include <DigiMIDI.h>

#define PINLED 1  //onboard led
#define PINSENSOR 2 //radar sensor
#define NOTE 99  //midi note
#define VELO 64  //midi velocity
#define CHAN 9  //midi channel

DigiMIDIDevice midi;

int state = 0;

void setup() {
  pinMode(PINSENSOR, INPUT);
  pinMode(PINLED, OUTPUT);
  midi.sendNoteOff(NOTE, VELO, CHAN);
}

void loop() {
  midi.update();

  if (digitalRead(PINSENSOR) == 1) {
    if (state == 0) {
      digitalWrite(PINLED, HIGH);
      midi.sendNoteOn(NOTE, VELO, CHAN);
      state = 1;
    }
  } else {
    if (state == 1) {
      digitalWrite(PINLED, LOW);
      midi.sendNoteOff(NOTE, VELO, CHAN);
      state = 0;
    }
  }
  midi.delay(100);
}

The device show up as a MIDI device and the following code is an example of how to connect to it in SuperCollider...

MIDIClient.init;
MIDIIn.connectAll;
MIDIdef.noteOn(\radarOn, {|...args| [\radarOn, args].postln}, 99);
MIDIdef.noteOff(\radarOff, {|...args| [\radarOff, args].postln}, 99);

MIDIdef.trace;

f0mid

Wireless MIDI <-> OSC bridge using an ESP8266-01. This circuit is extremely cheap to build. Schematics, Arduino code and examples for SuperCollider below.

I'm using the great Arduino MIDI Library that allows for both sending and receiving a multitude of MIDI messages including sysex, system realtime and time code messages. My Arduino code just converts all these to/from OSC and send or broadcast them over WiFi network.

Note: sending MIDI over WiFi UDP is generally a bad idea. There will be delays, glitches and even lost messages (hanging notes). This is specially problematic for MIDI time code (sync) messages. That said, in many situations this is ok and in my tests with simple note on/off messages + bend and control, things seem to work just fine.

f0mid

The circuit takes in 5V and then the regulator steps this down to 3.3V. Notice the huge 220uF capacitor that's needed to provide power for the ESP8266 during its infamous current draw spikes.

f0mid_schematics

SuperCollider example code...

//http://fortyseveneffects.github.io/arduino_midi_library/a00041.html
//http://fortyseveneffects.github.io/arduino_midi_library/a00043.html

OSCFunc.trace(true, true);
OSCFunc.trace(false);

n= NetAddr("f0mid.local", 18120);  //ip of esp8266
n.sendMsg(\ip, 192, 168, 1, 99);  //receiver ip (laptop - by default this is x.x.x.255 (broadcast))
n.sendMsg(\port, 57120);  //set receiver port (by default this is 57120)

n.sendMsg(\thru, 0);  //off
n.sendMsg(\thru, 1);  //full (default)
n.sendMsg(\thru, 2);  //same channel
n.sendMsg(\thru, 3);  //different channel

n.sendMsg(\noteOn, 66, 127, 1);  //(note, velo, chan)
n.sendMsg(\noteOff, 66, 0, 1);  //(note, velo, chan)
n.sendMsg(\afterTouchPoly, 50, 60, 3);  //poly pressure (note, press, chan)
n.sendMsg(\controlChange, 1, 64, 3);  //(num, val, chan)
n.sendMsg(\programChange, 10, 4);  //(num, chan)  note the -1 offset
n.sendMsg(\afterTouchChannel, 40, 2);  //(press, chan)
n.sendMsg(\pitchBend, -8000, 1);  //(bend, chan)  -8192 - 8191
n.sendMsg(\sysEx, 240, 14, 5, 0, 5, 247);  //(sysex) - 240 a b c d e ... 247

//realtime
(
var clock= 0xf8;  //248
var start= 0xfa;  //250
var continue= 0xfb;  //251
var stop= 0xfc;  //252
Routine.run({
        n.sendMsg(\realTime, start);
        100.do{
                n.sendMsg(\realTime, clock);
                0.02.wait;
        };
        n.sendMsg(\realTime, stop);
        1.wait;
        n.sendMsg(\realTime, continue);
        100.do{
                n.sendMsg(\realTime, clock);
                0.02.wait;
        };
        n.sendMsg(\realTime, stop);
});
)
n.sendMsg(\realTime, 0xfe);  //active sensing
n.sendMsg(\realTime, 0xff);  //system reset

n.sendMsg(\songPosition, 100);
n.sendMsg(\songSelect, 3);
n.sendMsg(\tuneRequest);

n.sendMsg(\beginNrpn, 10, 3);  //(number, channel)
n.sendMsg(\nrpnDecrement, 40, 3);  //(amount, channel)
n.sendMsg(\nrpnIncrement, 30, 3);  //(amount, channel)
n.sendMsg(\endNrpn, 3);  //(channel)

n.sendMsg(\beginRpn, 10, 4);  //(number, channel)
n.sendMsg(\rpnDecrement, 40, 4);  //(amount, channel)
n.sendMsg(\rpnIncrement, 30, 4);  //(amount, channel)
n.sendMsg(\endRpn, 4);  //(channel)

//--simple midi synth example
(
s.latency= 0.02;
s.waitForBoot{
        var busBend= Bus.control(s);
        var busCF= Bus.control(s);
        var busRQ= Bus.control(s);
        var busVol= Bus.control(s);
        var busPan= Bus.control(s);
        busBend.value= 0;
        busCF.value= 1000;
        busRQ.value= 0.5;
        busVol.value= 0.5;
        busPan.value= 0;
        SynthDef(\note, {|freq= 400, amp= 0.5, gate= 1, busBend, busCF, busRQ, busVol, busPan|
                var env= EnvGen.ar(Env.adsr(0.01, 1, 0.85, 0.1), gate, amp, doneAction:2);
                var bend= In.kr(busBend).lag(0.01);
                var cf= In.kr(busCF).lag(0.01);
                var rq= In.kr(busRQ).lag(0.01);
                var vol= In.kr(busVol).lag(0.01);
                var pan= In.kr(busPan).lag(0.01);
                var src= BLowPass4.ar(VarSaw.ar((freq+bend).midicps), cf, rq);
                OffsetOut.ar(0, Pan2.ar(src*env, pan, vol));
        }).add;
        d= ();
        OSCdef(\f0mid, {|msg|
                switch(msg[1],
                        \activeSensing, {},
                        \noteOn, {
                                d.at(msg[2]).set(\gate, 0);
                                d.put(msg[2], Synth(\note, [
                                        \freq, msg[2],
                                        \amp, msg[3].lincurve(0, 127, 0, 0.75, 4),
                                        \busBend, busBend,
                                        \busCF, busCF,
                                        \busRQ, busRQ,
                                        \busVol, busVol,
                                        \busPan, busPan
                                ]));
                        },
                        \noteOff, {
                                d.at(msg[2]).set(\gate, 0);
                                d.put(msg[2], nil);
                        },
                        \pitchBend, {
                                busBend.value= msg[2]/8192;
                        },
                        \controlChange, {
                                switch(msg[2],
                                        1, {
                                                busCF.value= msg[3].linexp(0, 127, 400, 4000);
                                        },
                                        7, {
                                                busVol.value= msg[3].lincurve(0, 127, 0, 1, 0);
                                        },
                                        10, {
                                                busPan.value= msg[3].linlin(0, 127, -1, 1);
                                        },
                                        74, {
                                                busRQ.value= msg[3].linlin(0, 127, 2, 0.1);
                                        },
                                        {("todo control: "+msg).postln}
                                );
                        },
                        {("todo command: "+msg).postln}
                );
        }, \f0mid);
        CmdPeriod.doOnce({
                busBend.free;
                busCF.free;
                busRQ.free;
                busVol.free;
                busPan.free;
        });
};
)

//mtc - receive
(
var a= MIDISMPTEAssembler({|time, format, dropFrame, srcID|
        [time, format, dropFrame, srcID].postln;
        //time.postln;
});
OSCdef(\f0mid, {|msg, time, addr|
        var chan, valu;
        if(msg[1]==\mtcQF, {
                chan= msg[2].rightShift(4);  //nibble high
                valu= msg[2].bitAnd(15);  //nibble low
                if(chan==7, {
                        valu= switch(valu,
                                6, {valu= 96},  //30fps
                                4, {valu= 64},  //30fps drop
                                2, {valu= 32},  //25fps
                                0, {valu= 0}     //24fps
                        );
                });
                a.value(addr.addr.bitAnd(255), chan, valu);
        });
}, \f0mid);
)

//mtc - send (kind of works - wslib quark required)
(
var startSec= 0;
var t= Main.elapsedTime-startSec;
var a= SMPTE(0, 30);
Routine.run({
        var chan= 0, valu= 0;
        inf.do{
                a.newSeconds(Main.elapsedTime-t);
                switch(chan,
                        0, {valu= a.frames.asInteger.bitAnd(15)},
                        1, {valu= a.frames.asInteger.rightShift(4)},
                        2, {valu= a.seconds.asInteger.bitAnd(15)},
                        3, {valu= a.seconds.asInteger.rightShift(4)},
                        4, {valu= a.minutes.asInteger.bitAnd(15)},
                        5, {valu= a.minutes.asInteger.rightShift(4)},
                        6, {valu= a.hours.asInteger.bitAnd(15)},
                        7, {
                                valu= a.hours.asInteger.bitAnd(1).rightShift(4);
                                switch(a.fps,
                                        30, {valu= valu.bitOr(6)},  //30fps
                                        //30fps drop not supported
                                        25, {valu= valu.bitOr(2)},  //25fps
                                        //24, {valu= valu.bitOr(0)}     //24fps
                                );
                        }
                );
                n.sendMsg(\mtcQF, chan.leftShift(4)+valu.bitAnd(15));
                chan= chan+1;
                if(chan==8, {
                        chan= 0;
                });
                (1/(a.fps*4)).wait;
        };
});
)

update 180421: added soft access-point option as well as OSC commands for setting the receiver IP and port
update 181211: removed soft access-point and simplified WiFi setup with the wifimanager library

AttachmentSize
Package icon f0mid_firmware.zip3.92 KB

f0dim

This simple addition/hack lets me control the Velleman K8064 DC dimmer kit via wireless OSC or serial. It's based on an ESP8266. The kit is isolated, can dim 220V/110V and is rated for up to 750W loads.
Normally one control it using 0-12V but by replacing a resistor (R16) it's possible to do it with the 0-3.3V PWM signal that the ESP outputs.

f0dim

I probably should cut some air ventilation holes, but so far it hasn't gotten hot inside.

f0dim_schematics

Arduino code for the ESP8266...

//f.olofsson2017

// * install OSC from https://github.com/CNMAT/OSC
// * edit where it says EDIT below
// * choose board: "Generic ESP8266 Module" 160 MHz

//osc protocol: /dim pwm fade
//  pwm should be 0.0-1.0
//  fade should be 0.0-1.0 (1.0=instant)
//serial protocol: 253 254 pwmhi pwmlo fadehi fadelow 255
//  pwm hi and lo should be 0-1023
//  fade hi and lo should be 0-1023 (1023=instant)

#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
#include <OSCMessage.h>

#define PORT 15551  //receiving osc port
#define PINPWM 0
#define PAYLOAD 4
#define UPDATERATE 16
#define TRIES 100  //how many times try check for wifi connection at startup

const char *ssid = "wifinetwork"; //EDIT your accessPoint network name
const char *password = "wifipassword";  //EDIT your password
const char *espname = "f0dim";
WiFiUDP Udp;
bool wifi;

byte serial_index = 0;
byte serial_data[PAYLOAD];
unsigned long next_time;
float dim = 0.0, dim_target = 0.0, dim_fade = 1.0;

void setup() {
  analogWriteFreq(5000);   //5khz pwm
  Serial.begin(115200, SERIAL_8N1, SERIAL_RX_ONLY);
  pinMode(LED_BUILTIN, OUTPUT);
  pinMode(PINPWM, OUTPUT);
  analogWrite(PINPWM, 0);
  delay(10);
  WiFi.mode(WIFI_STA);
  WiFi.hostname(espname);
  WiFi.begin(ssid, password);
  byte cnt = 0;
  wifi = false;
  while ((WiFi.status() != WL_CONNECTED) && (cnt < TRIES)) {
    delay(100);
    cnt++;
    digitalWrite(LED_BUILTIN, cnt % 2);
  }
  if (WiFi.status() == WL_CONNECTED) {
    Udp.begin(PORT);
    wifi = true;
  }
  digitalWrite(LED_BUILTIN, !wifi); //blue led on if connected to wifi
}

void oscDim(OSCMessage &msg) {
  dim_target = msg.getFloat(0);
  dim_fade = msg.getFloat(1);
}

void loop() {

  //--serial input
  while (Serial.available() > 0) {
    byte val = Serial.read();
    if ((serial_index == 0) && (val == 253)) {
      serial_index = 1;
    } else if ((serial_index == 1) && (val == 254)) {
      serial_index = 2;
    } else if ((serial_index >= 2) && (serial_index < (PAYLOAD + 2))) {
      serial_data[serial_index - 2] = val;
      serial_index++;
    } else if ((serial_index == (PAYLOAD + 2)) && (val == 255)) {
      dim_target = ((serial_data[0] << 8) + serial_data[1]) / 1023.0;
      dim_fade = ((serial_data[2] << 8) + serial_data[3]) / 1023.0;
      serial_index = 0;
    } else {
      serial_index = 0;
    }
  }

  //--osc input
  if (wifi) {
    int packetSize = Udp.parsePacket();
    if (packetSize) {
      OSCMessage oscMsg;
      while (packetSize--) {
        oscMsg.fill(Udp.read());
      }
      if (!oscMsg.hasError()) {
        oscMsg.dispatch("/dim", oscDim);
      }
    }
  }

  //--fading
  if (millis() >= next_time) {
    next_time = millis() + UPDATERATE;
    if (dim < dim_target) {
      dim = dim + dim_fade;
      if (dim > dim_target) {
        dim = dim_target;
      }
    } else if (dim > dim_target) {
      dim = dim - dim_fade;
      if (dim < dim_target) {
        dim = dim_target;
      }
    }
    analogWrite(PINPWM, int(dim * 1023));
  }
}

SuperCollider example code...

//f0dim can be controlled either via osc or serial
n= NetAddr("192.168.1.105", 15551);
n.sendMsg(\dim, 1.0, 1.0);  //set 100% instantly
n.sendMsg(\dim, 0.5, 1.0);  //set 50% instantly
n.sendMsg(\dim, 0.0, 1.0);  //set 0% instantly
n.sendMsg(\dim, 1.0, 0.001);  //slow fade in
n.sendMsg(\dim, 0.0, 0.0005);  //slower fade out

SerialPort.listDevices;
(
~port= SerialPort("/dev/tty.usbserial123", 115200, crtscts: true);  //EDIT serialport
CmdPeriod.doOnce({~port.close});
f= {|pwm= 1023, fade= 1023|
        Int8Array[253, 254, pwm>>8, pwm%256, fade>>8, fade%256, 255];
};
)

~port.putAll(f.value(1023, 1023));  //set 100% instantly
~port.putAll(f.value(512, 1023));  //set 50% instantly
~port.putAll(f.value(0, 1023));  //set 0% instantly
~port.putAll(f.value(1023, 3));  //slow fade in
~port.putAll(f.value(0, 2));  //slower fade out

~port.close;

udssrKontroll

After many years I finally got around to rebuild one of these boxes.

So this old Soviet made device is now a wireless controller that send out OSC. There are in total 34 buttons, 16 knobs and an additional RGB status led. It automatically connects via WiFi to MaxMSP or SuperCollider and run on 5V (USB powerbank).

KiCad schematics, Arduino firmware, SuperCollider classes and MaxMSP abstractions attached below.

udssrKontroll01

The inside is quite a mess. I use an ATmega168 together with six 4051 multiplexers to read all the inputs. the WiFi module is an ESP8266-01.

udssrKontroll02

update 190124: v1.1 fixed a small but breaking bug in the ATmega168 code.

AttachmentSize
Package icon udssrKontroll_1.1.zip116.32 KB

Pages

Subscribe to RSS - electronics