«first  …8 9 10 11 12 13 14 last»


2013-09-30 16:25 electronics

For my upcoming solo at the Sound of Stockholm festival, I decided to rebuild my main wireless controller. Previously it used a Nordic nRF24L01+ transceiver as radio module, but the range wasn't great and communication often broke down during live performances. I don't know much about these things, but I guess that when the audience bring in mobile phones the radio spectrum quickly fills up.

So I constructed a new circuit from scratch and while I was at it also reworked the resistor ladders and other cablings inside the box. Now it's using WiFi. The new radio module I installed in the controller box is Adafruit's CC3000 WiFi Breakout, and as receiver, I use a small tl-wr703n WiFi router running OpenWRT.

The wireless range is now excellent and everything is a lot more stable. I could also drastically reduce the amount of data being sent by fixing the resistor ladders.

Circuit... (basically just one ATmega382p, a 16 channel ADC, voltage divider resistors and the WiFi module)

redThermoKontroll2 photo 0


redThermoKontroll2 photo 1


redThermoKontroll2 photo 2

100 Ohm resistor ladder...

redThermoKontroll2 photo 3

Below are parts list, schematics, firmware and a SuperCollider class.

redThermoKontroll (WiFi version) parts list:

1   4067 multiplexer
1   ATmega328p
1   16 MHz crystal
2   27p ceramic caps
1   socket 2x14 (28pin)
1   Adafruit CC3000 module
1   1x9 pin header
1   1x10 pin header
1   1x8 pin header
1   1x5 pin header

1   resettable fuse 1A
1   Zener diode 5.6V
1   0.1uF cap
1   100uF electrolytic cap
1   470uF electrolytic cap

10  220, 270, 330, 680, 1K, 2, 10K resistors
1   220 resistor for led

1   power jack
1   LDR
1   red led

redThermoKontroll schematics 2

//redFrik 2013 GNU GPL v2
//updated 150920 - automatically send to IP x.x.x.99 (constructed from given DHCP IP)

//make sure to use Paul Stoffregen's branch of the Adafruit_CC3000 library
//and cc3000 firmware 1.24 (1.11.1)
//select board UNO and upload to a ATMEGA328P chip (using a usbtinyisp programmer)
//test in terminal with command: nc -ul 58100

#include <Adafruit_CC3000.h>
#include <ccspi.h>
#include <SPI.h>

#define WLAN_SSID       "xxx"
#define WLAN_PASS       "yyy"

#define PORT            58100
#define DELAY           10
#define PINGRATE        2000

#define ADAFRUIT_CC3000_IRQ   3   //mega328 pin 5
#define ADAFRUIT_CC3000_VBEN  8   //mega328 pin 14
#define ADAFRUIT_CC3000_CS    10  //mega328 pin 16
Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBEN, SPI_CLOCK_DIVIDER);
Adafruit_CC3000_Client client;

uint8_t buf[16];
byte last[] = {
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0

byte cnt = 0;
unsigned long time;

void setup(void) {
  Serial.begin(115200);  //debug

  pinMode(7, OUTPUT);         //led
  pinMode(6, OUTPUT);         //4067 d (DDD6)
  pinMode(5, OUTPUT);         //4067 c (DDD5)
  pinMode(4, OUTPUT);         //4067 b (DDD4)
  pinMode(2, OUTPUT);         //4067 a (DDD2)
  pinMode(A5, INPUT);         //4067 x
  pinMode(A4, INPUT_PULLUP);  //capa1 (right)
  pinMode(A3, INPUT_PULLUP);  //capa0 (left)
  pinMode(A2, INPUT_PULLUP);  //swiUp (up)
  pinMode(A1, INPUT_PULLUP);  //swiUp (down)
  pinMode(A0, INPUT_PULLUP);  //swiOn

  if (!cc3000.begin()) {
    Serial.println(F("Unable to initialise the CC3000! Check your wiring?"));
    while (1);
  Serial.println(F("\nDeleting old connection profiles"));
  if (!cc3000.deleteProfiles()) {
    while (1);
  Serial.println(F("Request DHCP"));
  while (!cc3000.checkDHCP()) {
    delay(100); // ToDo: Insert a DHCP timeout!
  uint32_t ipAddress, netmask, gateway, dhcpserv, dnsserv;
  while (!cc3000.getIPAddress(&ipAddress, &netmask, &gateway, &dhcpserv, &dnsserv)) {
    Serial.println(F("Unable to retrieve the IP Address!"));
  Serial.print(F("\nCC3000 IP Addr: "));
  //the following sets receiver to x.x.x.99 and assume cc3000 will never get exactly that IP itself
  ipAddress = cc3000.IP2U32(ipAddress >> 24 & 255, ipAddress >> 16 & 255, ipAddress >> 8 & 255, 99);
  Serial.print(F("\nReceiver IP Addr: "));
  client = cc3000.connectUDP(ipAddress, PORT);

  //--OSC message [/tk2, index, value]
  buf[0] = 47;   // /
  buf[1] = 116;  // t
  buf[2] = 107;  // k
  buf[3] = 50;   // 2
  buf[4] = 0;
  buf[5] = 0;
  buf[6] = 0;
  buf[7] = 0;
  buf[8] = 44;   // ,
  buf[9] = 105;  // i
  buf[10] = 0;
  buf[11] = 0;
  buf[12] = 0;   //msb - index
  buf[13] = 0;   //
  buf[14] = 0;   //
  buf[15] = 0;   //lsb - value

void loop(void) {
  byte val;

  //--analogue inputs
  for (byte i = 0; i < 13; i++) {
    delay(1);                //not sure if needed
    val = analogRead(A5) >> 2; //from 10 to 8 bits
    if (val != last[i]) {
      sendOsc(i, val);
      last[i] = val;

  //--digital inputs
  val = PINC & 0b00011111;
  if (val != last[13]) {
    sendOsc(13, val);
    last[13] = val;

  if (millis() - time > PINGRATE) {
    sendOsc(127, 0);      //ping
    time = millis();

void sendOsc(byte index, byte val) {
  buf[12] = index;
  buf[15] = val;
  if (cnt++ % 2 == 0) {   //toggle red led
    PORTD &= ~_BV(DDD7);
  else {
    PORTD |= _BV(DDD7);
  client.write(buf, sizeof(buf));

void setChan(byte index) {
  switch (index) {
    case 0:
      PORTD &= ~_BV(DDD2);        //low
      PORTD &= ~_BV(DDD4);        //low
      PORTD &= ~_BV(DDD5);        //low
      PORTD &= ~_BV(DDD6);        //low
    case 1:
      PORTD |= _BV(DDD2);    //high
      PORTD &= ~_BV(DDD4);        //low
      PORTD &= ~_BV(DDD5);        //low
      PORTD &= ~_BV(DDD6);        //low
    case 2:
      PORTD &= ~_BV(DDD2);        //low
      PORTD |= _BV(DDD4);    //high
      PORTD &= ~_BV(DDD5);        //low
      PORTD &= ~_BV(DDD6);        //low
    case 3:
      PORTD |= _BV(DDD2);    //high
      PORTD |= _BV(DDD4);    //high
      PORTD &= ~_BV(DDD5);        //low
      PORTD &= ~_BV(DDD6);        //low
    case 4:
      PORTD &= ~_BV(DDD2);        //low
      PORTD &= ~_BV(DDD4);        //low
      PORTD |= _BV(DDD5);    //high
      PORTD &= ~_BV(DDD6);        //low
    case 5:
      PORTD |= _BV(DDD2);    //high
      PORTD &= ~_BV(DDD4);        //low
      PORTD |= _BV(DDD5);    //high
      PORTD &= ~_BV(DDD6);        //low
    case 6:
      PORTD &= ~_BV(DDD2);        //low
      PORTD |= _BV(DDD4);    //high
      PORTD |= _BV(DDD5);    //high
      PORTD &= ~_BV(DDD6);        //low
    case 7:
      PORTD |= _BV(DDD2);    //high
      PORTD |= _BV(DDD4);    //high
      PORTD |= _BV(DDD5);    //high
      PORTD &= ~_BV(DDD6);        //low
    case 8:
      PORTD &= ~_BV(DDD2);        //low
      PORTD &= ~_BV(DDD4);        //low
      PORTD &= ~_BV(DDD5);        //low
      PORTD |= _BV(DDD6);    //high
    case 9:
      PORTD |= _BV(DDD2);    //high
      PORTD &= ~_BV(DDD4);        //low
      PORTD &= ~_BV(DDD5);        //low
      PORTD |= _BV(DDD6);    //high
    case 10:
      PORTD &= ~_BV(DDD2);        //low
      PORTD |= _BV(DDD4);    //high
      PORTD &= ~_BV(DDD5);        //low
      PORTD |= _BV(DDD6);    //high
    case 11:
      PORTD |= _BV(DDD2);    //high
      PORTD |= _BV(DDD4);    //high
      PORTD &= ~_BV(DDD5);        //low
      PORTD |= _BV(DDD6);    //high
    case 12:
      PORTD &= ~_BV(DDD2);        //low
      PORTD &= ~_BV(DDD4);        //low
      PORTD |= _BV(DDD5);    //high
      PORTD |= _BV(DDD6);    //high
void flash(int num) {
  for(byte i= 0; i<num; i++) {
    digitalWrite(7, HIGH);
    digitalWrite(7, LOW);

p5 Tweets

2013-08-27 10:44 visuals

Constrains - I love them. Inspired by Abe's twitter experiments, I've also played with creating small one line Processing programs that are 140 characters long.

Below is a video of number 0002, the twitter code tweets and screenshots. Note that many but not all are animations. Copy and paste the lines into Processing (2.0) to try them out.


int i;noStroke();size(999,900);for(i=0;i<999;i++){fill(255,0,0,9);rect(i%99,i,i,i);}for(i=0;i<999;i++){fill(0,200,0,3);rect(i,i,i,i);}// #p5


int j,i=0;void setup(){size(1200,900,P3D);frameRate(999);}void draw(){for(j=0;j<99;)rect(i++%(1199-j++),int(i/99)%(999-j),i%12,j%16);}// #p5


int s=900,j,i=j=0;void setup(){size(s,s);fill(0,9);textSize(80);}void draw(){text(i+j,(sin(i++)/3+0.3)*s,(cos(j+++(i/4e3))/3+0.5)*s);}// #p5


int s=900,j,i=j=0;void setup(){size(s,s);stroke(255,9);fill(9,3);}void draw(){quad(i++,j++,j,i,s-i,i-50,s-j,j);i=(i<<j%4)%1200;j=j%s;}// #p5


int s=900,i=0;void setup(){size(s,s,P3D);stroke(255,0,0);fill(10,4);}void draw(){translate(i++%s,s/2);rotate(float(i)/s);sphere(i%s);}// #p5


int s=900;float i=0;void setup(){size(s,s,P3D);stroke(99,9);fill(0,2);}void draw(){translate(i++%s,s/2);rotate(cos(i/50));box(i%s/3);}// #p5


background(0);noStroke();for(float i=0;i<99;i=i+0.0252){size(1200,900,P3D);fill(255,0,0,60);translate(i+9,i);rotate(i*1.8);sphere(i);}// #p5


void setup(){size(1600,900);background(255);}void draw(){textSize(millis()%1200);fill(second()*4,0,0,second());text(millis(),10,880);}// #p5


float j,i=0;void setup(){size(1200,900,P3D);}void draw(){for(j=0;j<133;j++){rect(9*j+1,sin((i+++j)*0.75/cos(j/99)/5e3)*99+450,9,9);};}// #p5


float i,k=450;void setup(){size(900,900,P3D);textSize(k);}void draw(){translate(k,k);fill(i%1*k/2,60);rotate(i+=+.01);text("$",99,0);}// #p5


int i,j,k=1200;void setup(){size(k,900);fill(255,200);}void draw(){background(0);for(i=0;i<8e3;)text(i++*j/k%k,i%131*9,i/131*16);j++;}// #p5


int j=200,i=900;size(j*6,i,P3D);lights();translate(700,540);for(i=1;i<j;){fill(i/2,50);rotate(j/i);translate(i,i,-2.7);sphere(i+++j);}// #p5


int j=480,i=900;size(j*3,i,P3D);noStroke();lights();translate(660,j);for(i=1;i<j;){fill(i,0,0,10);rotate(i/4e4,1.1,2.2,3.3);box(i++);}// #p5


int s=900,i=0;void setup(){size(1200,s,P3D);}void draw(){translate(600,450);rotateX(i*.0021);fill(i++%256,30);sphere(sin(i*.0014)*s);}// #p5


int i,s=900;void setup(){size(s,s);frameRate(1e4);stroke(255,25);}void draw(){fill(i++%89,0,0,127);rect(i%90*9,i%91*9,i*i%92,i*i%93);}// #p5


int i,s=900,t=1200;void setup(){size(t,s);noStroke();}void draw(){fill(i++%256,25);quad(i%t,i/3%s,i/4%t,i%s,i/5%t,i/4%s,i/3%t,i/2%s);}// #p5


int t=0;void setup(){size(900,900);background(0);stroke(255,9);}void draw(){translate(450,450);line(sin(t)*421,cos(t++)*400,t%9,t%9);}// #p5


int s=900;size(1600,s);fill(255,9);while(s>9){rotate(1e-3);arc(s+420,s,s,s,0,7);arc(1000-s,s+100,s,s,0,7);arc(s+500,400-s,s,s--,0,4);}// #p5


int i,j,s=900;void setup(){size(s,s,P3D);smooth(8);}void draw(){stroke(i);line(i,j,s-j,i);if(j%5<1){i=(i+1)%s;}if(i%11<1){j=(j+i)%s;}}// #p5


int s=900;void setup(){size(1200,s,P3D);}void draw(){fill(s,50);translate(sin(s)*110+600,cos(s)*99+450);rotate(s);box(s);s=(s+1)%900;}// #p5
p5tweet screenshot1p5tweet screenshot2p5tweet screenshot3p5tweet screenshot4p5tweet screenshot5p5tweet screenshot6p5tweet screenshot7p5tweet screenshot8p5tweet screenshot9p5tweet screenshot10p5tweet screenshot11p5tweet screenshot12p5tweet screenshot13p5tweet screenshot14p5tweet screenshot15p5tweet screenshot16p5tweet screenshot17p5tweet screenshot18p5tweet screenshot19p5tweet screenshot20

Arduino Programming via Soundcard

2013-08-08 19:13 electronics, supercollider

With lots of study of the AudioBoot_V2_0 Java code by Chris at roboterclub-freiburg.de, I managed to write SuperCollider code for uploading sketches to an Arduino via the soundcard. no FTDI chip needed!

It's a very cheap solution for programming barebone Arduinos (well, ATmega168 microcontrollers really). You only need a few resistors, a capacitor and a mega168. The only difficult part is to 'initialize' this microcontroller by burning the special bootloader on to it. This requires an AVR programmer of some sort (STK500, USBtinyISP etc).

The preparation steps are as follows...

  1. Burn the bootloader on to a mega168
  2. Build the barebone circuit
  3. Prepare the Arduino IDE
  4. Install the RedArduino class

After that one can compile HEX files in the Arduino IDE and upload them using SuperCollider and a standard audio cable.

1. Burn the bootloader on to a mega168

The trick behind all this is the special 'sound enabled' bootloader that I found here... www.hobby-roboter.de/forum/viewtopic.php?f=4&t=127. I downloaded the AudioBoot_V2_0.zip file and used my STK500 AVR programmer together with the great AVR Crosspack. The terminal command I used for burning the bootloader was the following...

avrdude -v -p m168 -b 115200 -P /dev/tty.PL2303-000013FA -c stk500v2 -U flash:w:/Users/asdf/arbeten/sc/scAudioino/AudioBoot_V2_0/Atmega_Source/chAudioBoot_ATMEGA168_IN_PD1_LED_PB5.hex -U lfuse:w:0xE2:m -U hfuse:w:0xDF:m -U efuse:w:0xFA:m

2. Build the barebone circuit

Then I built a minimal and barebone Arduino circuit after the schematics found here... www.hobby-roboter.de/forum/viewtopic.php?f=4&t=128&p=531. Again credit to Chris.

This is the schematics I drew...

audioino schematics

And here the resulting circuit...

audioino photo

I run it off 4.5V (3 batteries) but it could also be powered from the USB port.

3. Prepare the Arduino IDE

To compile HEX files for this barebone Arduino, I needed to set up a custom board in the Arduino IDE. One way to do this is to create a new text file called boards.txt and put it inside a new folder in the Arduino/hardware folder. on macOS that could be something like ~/Documents/Arduino/hardware/BareBones/boards.txt. The boards.txt should contain the following...

minimal168.name=ATmega168 bare bone (internal 8 MHz clock)

Then restart the Arduino IDE and under boards, there should be a new option with mega168 and 8 MHz internal clock. I make sure this board is selected every time before compiling HEX files for sound uploading.

Another thing that needs to be done is to enable 'verbose compile' in the Arduino IDE preferences. That will print out the file path of the HEX file each time you compile a sketch.

4. Install the RedArduino class

I wrote a couple of classes for SuperCollider to help with the encoding and signal generation of HEX files. They're found in my redSys quark (under redTools) and are most easily installed from within SuperCollider itself with these commands...

Quarks.install("redSys");  //install. recompile after this

There are two helper classes and one main class. The RedIntelHex class parses HEX files and RedDifferentialManchesterCodeNegative helps to encode the signal as differential manchester code. The main class RedArduino figures out the paging of data and generates a bitstream that is played back using demand rate UGens.


I upload sketches by compiling them in Arduino IDE (click verify - not upload) and copy&paste the file path of the resulting HEX file into SuperCollider and the RedArduino's read method. I connect the left sound output channel to the barebone Arduino, put my mac laptop volume to ~80%. Last I press the reset button on the circuit and quickly (within seconds) call the upload method in SuperCollider. The led should blink slowly directly after a reset, and fast when receiving data.

Here's a video demonstrating how to do it. I'm just uploading the simple Blink example. Near the end, you will also hear how that sounds.

There's also some SuperCollider code I wrote (github.com/redFrik/udk09-Bits_and_Pieces/blob/master/udk130523/extras/uploadingArduino.scd) that will do the same thing but without the need of the redSys quark classes.

Trash or Treasure?

2013-08-07 17:15 electronics

Some weeks ago I found a Canon Pixma MP510 on the street. A "Photo All-in-One with economical single inks that prints, copies or scans in colour". Someone had thrown it away regarding it as a piece of junk. I saw a pile of gold.

Taking it apart I got...

  • four nice motors: two stepper and two DC motors
  • a 33x25 cm piece of glass
  • boxed and reusable 220V power supply
  • a small LCD colour display
  • a scanner head
  • some LEDs
  • five infrared sensors (paper sensors)
  • lots of screws and springs
  • wire and cog belts
  • some switch buttons
  • two USB jacks
  • various other components

canon photo 1 canon dismantled 2 canon parts 3

Alike makezine.com/projects/dont-waste-ewaste-unmaking-a-canon-printerscannerfax-into-parts/

USB Soundcards Mod

2013-08-06 17:50 electronics

To save a bit of power (and annoyance), I de-soldered the LEDs on two USB soundcards. I use these soundcards for battery-driven projects (Beaglebone Black) and every milliamp I can save counts.

The LogiLink soundcard had two easily removable LEDs. The red one indicated that the soundcard was connected and had power, and the green one started to blink when the card was in use (driver activated). Both functions I can easily live without.
The blue '3D-sound' card had a very tiny surface-mount led that I removed using two soldering irons.

Here some before and after photos...

usb soundcard photo 1 usb soundcard photo 2 usb soundcard photo 3 usb soundcard photo 4

Btw, I'd stay away from the LogiLink. It has a problem with audible noise coming from the PWM signal of the green blinking led. If you connect a mic like I'm doing, a beep beep beep kind of sound leaks into the mic. And removing the led doesn't help. Maybe there's something in the software driver to control it, but I doubt it.

Cheap 4-channel Videoplayer

2013-07-30 00:18 visuals

For the dance piece Ich(a) by Zufit Simon I constructed a system with four Raspberry Pi mini-computers and buttons to trigger playback of four video streams. As the videos didn't need to run in exact frame-by-frame sync, this was a very cheap way to get four channel high-quality video playback. Total cost was about (RPi 28 * 4) + (SD card 6 * 4) + (5V power 1 * 7) ≈ 141 Euro. I chose the model A of the Raspberry Pi to keep the cost and power consumption down. The four computers share a 5V power supply of 2 amps and are powered over the GPIO pins. Video cables run 50 meters down to the stage and into separate flat-screen monitors. The monitors are built into boxes that can be piled up or rolled around independently.

The videos are stored on the 4 GB SD cards that also holds the Linux operating system. I converted the videos from DVD to MP4 using ffmpeg with the following settings...

ffmpeg -i concat:"/Volumes/MONITOR01_may2012_DVD/VIDEO_TS/VTS_01_1.VOB|/Volumes/MONITOR01_may2012_DVD/VIDEO_TS/VTS_01_2.VOB" -an -vcodec libx264 -profile:v high -preset fast -crf 18 -b-pyramid none -f mp4 MONITOR01_may2012.mp4

That'll take two chapters and convert to a single MP4 and skip the audio track (-an flag).

The Python program running on each computer is here below. It plays a video to the end and waits for a button trigger. If a button is pressed before the video is finished, it'll stop and jump to the next video - all in a cyclic fashion.

#for a Raspberry Pi running Raspbian
#this script will cycle through videos in sequence when a GPIO pin is grounded

#pinSwi (pulled up internally) - GND this pin to switch to the next video
#pinOff (pulled up internally) - GND this to shut down the system

videos= ['/home/pi/ICHA1.mp4', '/home/pi/MONITOR01_may2012.mp4', '/home/pi/BLACK.mp4', '/home/pi/FLESH.mp4', '/home/pi/TESTBILDER.mp4']
delays= [0, 0, 0, 0, 0]  #extra start delay time in seconds - one value for each video
pinSwi= 23
pinOff= 24

import pexpect
from time import sleep
import RPi.GPIO as GPIO
import os
GPIO.setup(pinSwi, GPIO.IN, pull_up_down= GPIO.PUD_UP)
GPIO.setup(pinOff, GPIO.IN, pull_up_down= GPIO.PUD_UP)

def main():
  os.system("clear && tput civis")  #clear and hide cursor
  index= 0  #keeps track of which video to play
  while True:
    omx= pexpect.spawn('/usr/bin/omxplayer -rp '+videos[index])
    omx.expect('Video')  #play
      if GPIO.input(pinOff)==False:
        omx.send('q')  #quit
        os.system("tput cnorm && sudo halt")
    omx.send('q')  #quit
    sleep(0.5)  #safety
    index= (index+1)%len(videos)

if __name__ == "__main__":

Instructions for installing

(you'll need a model B to prepare an SD card, but then move it over to the model A Raspberry Pi)

prepare the RPi

  • use Pi Filler to transfer 2013-05-25-wheezy-raspbian.img to the SD card
  • put the SD card in RPi model B
  • select 'Expand Filesystem' in and enable SSH under advanced in config menu
  • select 'Finish' and reboot
  • log in with pi/raspberry
  • sudo apt-get update
  • sudo apt-get upgrade
  • sudo apt-get install python-pexpect avahi-daemon

copy files from macOS

  • open a terminal window on the main computer
  • cd to folder with videos
  • edit the file f0videoplayer.py and select which videos to use
  • optionally add delay times if some videos should start later
  • scp f0videoplayer.py MONITOR01_may2012.mp4 ICHA1.mp4 BLACK.mp4 FLESH.mp4 TESTBILDER.mp4 pi@raspberrypi.local:/home/pi/

back to model B

  • sudo pico /etc/rc.local
  • add the following before the exit line: (sleep 1; python /home/pi/f0videoplayer.py) & # autostart video player
  • press ctrl+o to save and ctrl+x to exit
  • sudo halt

start model A

  • take out the SD card from model B and put it in model A
  • connect HDMI or composite video, GPIO pins and apply power - the first video should start
  • ground pin 23 to cycle through the videos
  • ground pin 24 to turn off the computer

Useful commands

(connect a keyboard to RPi model A, type pi/raspberry to log in)

sudo pkill omxplayer.bin #might need to write this without the terminal being visible


ssh-keygen -R raspberrypi.local     #useful for resetting ssh/scp after changing SD cards

It's not pretty but it's working. Some day I'll build it into a real rackmount box.

f0videoplayer photo




under the hood changes 2

2013-05-26 10:00 other

Updating this blog to Drupal 7. It is quite different from version 6 and things will be a bit chaotic for a while. Sorry that some content here will be unavailable for a few days.


  • 130607: fixed the layout and sound files should play again.

Arduino Live Coding

2013-05-17 17:54 livecoding

So here's some more in depth info on my performance at the live.code.festival / algorave in Karlsruhe.

Being fascinated since long by the sound of serial transmission, I got into trying to make music out of it in some way. By trial-and-error, I figured out that if I connect a small speaker to the TX line of an Arduino, I could upload programs that send serial data and listen to the sound of it.

It is all very basic: if I make the Arduino program send data with delays in between, it plays click rhythms. And programs with faster streams of data play tones. More elaborate combinations of delays and patterns of data produce chords, melodies and a variety of noises. So it works like some sort of one-bit music system that is nice and challenging to play with.

The programs I [live]code can look like this...

byte cnt= 0;
void setup() {
void loop() {

and the resulting sound is this... (raw and unfiltered)

and a more elaborate program...

byte cnt= 0;
void setup() {
void loop() {
  for(int i= 0; i<100; i++) {
  for(int i= 0; i<200; i++) {
  for(int i= 0; i<100; i++) {
  for(int i= 0; i<100; i++) {
  for(int i= 0; i<100; i++) {
  if(random(2)==0) {

sounds like this...

And of course, the sound of the uploading (verification really) is great in itself. It typically sounds like this... (raw and unfiltered)

I think the uploading sound changes subtly depending on program length and I also guess it will change with different Arduino bootloaders and whatever baud rate they are using.

And you also have a bit of control over the timbre of the sounds. Certain 8bit numbers are more square-wave like than others e.g. 170 (0b10101010), and 85 (0b01010101) sound more 'clean' and 15 (0b00001111) and 240 (0b11110000) also have a more distinct pitch.

Different baud rates have a huge effect on the sound - mainly working as frequency transposition.

But the real fun starts when one connects five Arduinos to a mixer and start playing with volumes, panning and filters. By having five Arduinos connected to a USB hub while running five copies of the Arduino IDE software, I can write little programs on the fly that will address the different boards and play different sounds on the TX lines. (Listening to the RX line also works but then the upload process fails. It'll require extra circuitry to tap into this data without disrupting the uploading).

The reason I used five Arduinos is that that's all I could connect to my laptop (2x USB) with my 4-port USB hub. That in combination with the limitation of computer screen space. It is hard to have more than five Arduino IDE programs open and visible at the same time.

Anyway, as the voltage of the standard Arduino is 5V and really a bit too much for audio equipment, I bring this down a bit with a simple voltage divider. I'm using a 10K and a 1K resistor.

arduinoLivecoding schematic

Here are some pictures of the setup. I'm using the Arduino clone Red board from SparkFun.

arduinoLivecoding board photo

The complete setup (without mixer and laptop)...

arduinoLivecoding boards photo

One issue with the setup is that one can't trust the Arduino IDE to remember which serial port it was connected to. So every time I start the program I need to double-check that the five Arduino IDE programs are set to the right Arduino board. And as I like to know which board is connected to which mixer channel, I also need to check that and possibly reconnect the sound cables.

Live at the live.code.festival in Karlsruhe (Algorave night 20 Apr 2013). Five Arduino boards all with their serial port (TX line) connected to a mixer (with simple protective circuitry in between). So all sounds are generated from what the Arduino boards are programmed to transmit serially. Note that the sound is heavily distorted. Sorry.

«first  …8 9 10 11 12 13 14 last»