🔍

experimental 8×8 synth with Arduino and PureData

step by step build up

hoock up the matrix first

Now lets flicker the matrix first 🙂


#define PIN_DIN 8
#define PIN_CLK 9
#define PIN_CS 10
#define NUM_DEVICES 1

#include <LedControl.h>

LedControl lc = LedControl(PIN_DIN, PIN_CLK, PIN_CS, NUM_DEVICES);


void setup() {
  lc.shutdown(0, false);

  // intensity level (0..15)
  lc.setIntensity(0, 15);

  lc.clearDisplay(0);
}

void loop() {

  int rx = (int)(random(8));
  int ry = (int)(random(8));

  if (random(100) > 50) {
    lc.setLed(0, rx, ry, true);
  } else {
    lc.setLed(0, rx, ry, false);
  }

}


two potentiometers and one cursor


#define PIN_DIN 8
#define PIN_CLK 9
#define PIN_CS 10
#define NUM_DEVICES 1

#include <LedControl.h>
LedControl lc = LedControl(PIN_DIN, PIN_CLK, PIN_CS, NUM_DEVICES);


void setup() {

  lc.shutdown(0, false);
  // intensity level (0..15)
  lc.setIntensity(0, 15);
  lc.clearDisplay(0);
}

void loop() {

  // read out both analog Pins from the potis
  int poti_1_in = analogRead(1); // values from 0 to 1024
  int poti_2_in = analogRead(2); // values from 0 to 1024

  // map the poti value to the matrix size
  int cx = int( map(poti_1_in, 0, 1024, 0,8   ));
  int cy = int( map(poti_2_in, 0, 1024, 0,8   ));

 // int cx = int(poti_1_in/128);

  // clear matrix and draw cursor 
  lc.clearDisplay(0);
  lc.setLed(0,cx, cy, true);

}


two potentiometers and one cursor now MIDIFIED 🙂

install the MIDIUSB.h lib to convert Arduino to USB Midi Controller
#define PIN_DIN 8
#define PIN_CLK 9
#define PIN_CS 10
#define NUM_DEVICES 1

#include <LedControl.h>
LedControl lc = LedControl(PIN_DIN, PIN_CLK, PIN_CS, NUM_DEVICES);

#include "MIDIUSB.h"


void setup() {

  lc.shutdown(0, false);
  // intensity level (0..15)
  lc.setIntensity(0, 15);
  lc.clearDisplay(0);
}

void loop() {

  // read out both analog Pins from the potis
  int poti_1_in = analogRead(1); // values from 0 to 1024
  int poti_2_in = analogRead(2); // values from 0 to 1024

  // map the poti value to the matrix size
  int cx = int( map(poti_1_in, 0, 1024, 0,8   ));
  int cy = int( map(poti_2_in, 0, 1024, 0,8   ));

  // clear matrix and draw cursor 
  lc.clearDisplay(0);
  lc.setLed(0,cx, cy, true);


   controlChange(0, 4, poti_1_in/8); // Set the value of controller 10 on channel 0 to a random value
   controlChange(0, 5, poti_2_in/8); // Set the value of controller 10 on channel 0 to a random value
   
    MidiUSB.flush();

    delay(10);

}

// -------------------------------------------------
// -------------MIDI CODE - DO NOT TOUCH -----------
// -------------------------------------------------

void controlChange(byte channel, byte control, byte value) {
  midiEventPacket_t event = {0x0B, 0xB0 | channel, control, value};
  MidiUSB.sendMIDI(event);
}

DOWNLOAD PD PATCH: basic_two_osc_synth