# data[].attributes.body
I've now combined all of my previous work to build a controller that has 2 thumb-stick controls, sends values from them as MIDI data over USB, uses the 'select' buttons on the controls to increment through MIDI channels, and also has an LCD display that shows the current MIDI channel selected, and the values coming from each controller.

So far I've only tested this with Pure Data, so I need to test with some other software applications to see how the device is recognised and functions as a MIDI controller.

One problem I did solve today was an issue with obsolete values remaining on the LCD display, most noticeable when changing from a higher value to a lower value, for example;
changing from '10' to '8', would display '80' , and from '100' to '76' would display '760'.

I've worked around this issue by checking the 'size' of the value, i.e., how many digits it will be represented by, and writing additional zeros before the value where required, for example;
'8' will display as '008', and '34' will display as '034'.

While I'm pretty happy with how the code is performing on my controller, the problem I now need to solve is the packaging and containment of the wiring before the project becomes usable.

# data[].attributes.body
First bit of code tested on the Pro Micro to take an analogue reading in and output it as MIDI data.
So far I've only tested this in Pure Data, but fingers crossed I'll be able to get a solution that works universally across any software.
The test simply reads a value from a 10k linear potentiometer and outputs a MIDI control value.

# data[].attributes.body
I had an incline that I would encounter some issues getting started with the new board, which I did, but thankfully they were fairly painless to resolve.

The first step I had to do was install the board to the Arduino IDE - The board installation guide on the Sparkfun website was easy to follow and this didn't take long.

One thing to note is that when selecting the board in the Arduino IDE, you will first select the board type - Sparkfun Pro Micro - and then have to go back to the Tools menu and select the exact type of Pro Micro you have, e.g., 5V/16MHz - it won't automatically select the right board, and uploading a sketch to the wrong board can apparently cause problems.

One issue I did experience occurred when uploading a sketch, where I would get a 'Device or resource busy' error.

After some googling I found that a process called 'modemmanager' was likely the cause - running the command " sudo stop modemmanager " resolved the issue, allowing me to successfully upload the sketch to the board (until next reboot - apparently removing modemmanager would be fine to stop the issue once and for all.)

# data[].attributes.body
First opportunity this evening to have a quick play with this new board.
(I had to wait to borrow a soldering iron and solder some headers to the board - pretty pleased with my soldering efforts too.)
A few additional steps to get going with this board when compared to the Uno board, which I will explain in a separate post.

# data[].attributes.body
Going to be adding one of these to the controller to give channel/program selection feedback.
(Some simple LED's would have also worked, but I thought this would be more fun)

# data[].attributes.attachment_link.description
Before wiring the LCD screen to your Arduino or Genuino board we suggest to solder a pin header strip to the 14 (or 16) pin count connector of the LCD screen, as you can see in the image above.

# data[].attributes.body
The weekend provided an opportunity to put the thumb-stick controller to use in a few live shows.

The controller worked really well for me, providing a simple, gestural way to manipulate parameters of my instruments.

It worked particularly well mapped to a sequencer/percussion instrument, where one axis of the stick was mapped to the rate of the sequencer, and the other axis mapped to tonal quality (where one direction gave a grittier, noisier sound, and the other a purer, more tonal sound).

Being able to use the thumb-stick select buttons to assign the controller to different 'channels' was really useful, although not having any indication on the device as to what 'channel' I had selected was a slight issue.

I think the next steps for me are to purchase a board with native USB capabilities, allowing me to make use of the MIDI over USB library - I think the Pro Micro will be the particular model I'll go for.

I'm also planning on adding a further 2 thumb-sticks to the controller (so 4 in total), and also adding some form of visual feedback to show what 'channel' the controller is set to - either in the form of some simple LED's, or possibly a small LCD screen.

# data[].attributes.body
I've slightly amended the scaling used in the sketch for the thumb controls - I now scale the readings by 0.060546875, which gives me a 62 number range (rather than a 10 number range), which gives me smoother / more precise control in pure data.
After I thought about it, it seemed silly to be throwing away a load of precision.

# data[].attributes.body
Here is the sketch I am using with the thumb-stick controllers.

I think I want to explore scaling the values in to wider ranges which I think will allow for greater precision in the end result.

# data[].attributes.body
A short demo of the thumb-sticks mapped to 4 oscillators (2 modulated pairs).

# data[].attributes.attachment_link.title
Thumb-stick Control / Arduino / Pure Data

# data[].attributes.attachment_link.description
A short exploration of using thumb-stick controls mapped to oscillators in an FM synth in Pure Data

# data[].attributes.body
Lot's of interesting papers on the topic of musical interface design available to download on the NIME 2017 conference website.

# data[].attributes.attachment_link.title
NIME 2017 Papers and Posters Proceedings

# data[].attributes.attachment_link.description
Self-resonating Feedback Cello: Interfacing gestural and generative processes in improvised performance

# data[].attributes.body
Interested to explore using these joystick controllers mapped to carrier/modulator wave amplitudes on an FM synth.

# data[].attributes.attachment_link.description
DESCRIPTIONThis is a joystick very similar to the 'analog' joysticks on PS2 (PlayStation 2) controllers. Directional movements are simply two potentiometers - o

# data[].attributes.body
This looks interesting...

# data[].attributes.attachment_link.description
DESCRIPTIONThe ZX Distance and Gesture Sensor is a touchless sensor that is capable of looking for simple gestures. Developed in conjunction with XYZ Interactiv

# data[].attributes.body
I've been experimenting with ways to further improve the stability of readings I'm getting from my 2 ultra-sonic sensors within Pure Data.
I've found pretty good results from quanitizing my readings by re-scaling numbers and then sending to an [int] object.
This removes a lot of low level fluctuation from the readings.
I'm also using a line object to smooth movement.

# data[].attributes.body
To try and improve the quality of data collected from my 2 sensors, I have added code to write readings in to an array, and then work out an average of those readings before sending to serial

# data[].attributes.headline
Reading 2 UltraSonic Sensors & Writing to Serial

# data[].attributes.subject
Reading 2 UltraSonic Sensors & Writing to Serial

# data[].attributes.body
I solved a particular challenge this week regarding how to read from 2 sensors, write out to a single serial data stream, and then separate the 2 streams within Pure Data.

I did this by scaling and constraining the values from my 2 sensors in to 2 discrete ranges - 0-110, & 111-200.*

I can then use a [moses] object in Pure Data to split values below 110 in one direction, and values above 110 in another.

*This range is (roughly) important - the Serial.Write method I'm using in the Arduino Sketch can only handle values between 0-255 - anything over that will be 'wrapped around', totally skewing our readings at the other end.

I also convert the data to a 'byte' variable type, since this is what Serial.Write is expecting to work with (I believe).

# data[].attributes.body
The KOBAKANT site also has some more general resources relating to electronics and Arduino.

# data[].attributes.attachment_link.description
This post covers a few different (very basic) techniques for amplifying various sound sources. On the one hand sound coming from circuits inside toys that make sound (toy piano, singing greeting cards, recording and playback modules...), as well as sound made by generating frequencies using a microcontroller such as the ATtiny or an arduino board.

# data[].attributes.body
Really fun day at a synth building workshop on Saturday where we explored using conductive fabrics and threads to control and manipulate our DIY noise makers.

Lot's of possibilities for designing interfaces that use stretch threads and fabrics in place of traditional mechanical interfaces.

The KOBAKANT DIY site is a useful resource for information and ideas.

# data[].attributes.attachment_link.readable_text
Welcome to the KOBAKANT DIY Wearable Technology Documentation

This website aims to be a comprehensible, accessible and maintainable reference resource, as well as a basis for further exploration and contribution.

Tools > Wireless

This post is a follow up to mqtt broker post. The devices that are connecting to MQTT broker (ESP, computer.. etc) is called "Client", and on client side you will be running some kind of software that act as a MQTT client that publish/subscribe data to broker. For example, on ESPs, we used "espMQTTclient" library [...]

Tools > Wireless

These are out notes from working with various MQTT Broker options, which we have used mostly to publish sensor data wirelessly from a Client running on an ESP32 Dev Module (programmed with Arduio) and then subscribe to this data from various other Clients: - another ESP32 dev module - a Processing sketch on a computer [...]

Conductive Materials > Meet the Materials

ETextiles rely on the existence of electrically conductive fibers, threads and fabrics that can be used in combination with textile techniques such as sewing, weaving and knitting. Most of these conductive materials are produced by industry for anti-static and EMF shielding purposes. The development and production of materials for crafting soft circuits and sensors is [...]

# data[].attributes.attachment_link.description
Welcome to the KOBAKANT DIY Wearable Technology Documentation This website aims to be a comprehensible, accessible and maintainable reference resource, as well as a basis for further exploration and contribution. Tools > Wireless This post is a follow up to mqtt broker post. The devices that are connecting to MQTT broker (ESP, computer..

# data[].attributes.body
Found this library to improve readings from the HC-SR04 ultrasonic sensor.

# data[].attributes.attachment_link.description
When I first received an ultrasonic sensor I was not happy with how poorly it performed. I soon realized the problem wasn't the sensor, it was the available ping and ultrasonic libraries causing the problem. The NewPing library totally fixes these problems, adds many new features, and breathes new life into these very affordable distance sensors.

# data[].attributes.body
Have 2 of these waiting to be hooked up to compare performance with the IR sensor.
I'm expecting these to be more accurate, but possibly less responsive, which might be a problem for a gestural interface.

# data[].attributes.attachment_link.readable_text
The HC-SR04 Ultrasonic Sensor is a very affordable proximity/distance sensor that has been used mainly for object avoidance in various robotics projects . It essentially gives your Arduino eyes / spacial awareness and can prevent your robot from crashing or falling off a table. It has also been used in turret applications, water level sensing, and even as a parking sensor. This simple project will use the HC-SR04 sensor with an Arduino and a Processing sketch to provide a neat little interactive display on your computer screen.

Parts Required:
Freetronics Eleven or any compatible Arduino.
HC-SR04 Ultrasonic Sensor
Mini Breadboard 4.5cm x 3.5cm
Protoshield and female header pins (not essential - but makes it more tidy)
Wires to connect it all together

The above sketch was created using Fritzing.

Arduino Code:
You can download the Arduino IDE from this site.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60

/*
 HC-SR04 Ping distance sensor:
 VCC to arduino 5v
 GND to arduino GND
 Echo to Arduino pin 7
 Trig to Arduino pin 8

 This sketch originates from Virtualmix: http://goo.gl/kJ8Gl
 Has been modified by Winkle ink here: http://winkleink.blogspot.com.au/2012/05/arduino-hc-sr04-ultrasonic-distance.html
 And modified further by ScottC here: http://arduinobasics.blogspot.com.au/2012/11/arduinobasics-hc-sr04-ultrasonic-sensor.html
 on 10 Nov 2012.
 */


#define echoPin 7  // Echo Pin
#define trigPin 8  // Trigger Pin
#define LEDPin 13  // Onboard LED

int maximumRange = 200; // Maximum range needed
int minimumRange = 0; // Minimum range needed
long duration, distance; // Duration used to calculate distance

void setup() {
 Serial.begin (9600);
 pinMode(trigPin, OUTPUT);
 pinMode(echoPin, INPUT);
 pinMode(LEDPin, OUTPUT); // Use LED indicator (if required)
}

void loop() {
/* The following trigPin/echoPin cycle is used to determine the
 distance of the nearest object by bouncing soundwaves off of it. */
 digitalWrite(trigPin, LOW);
 delayMicroseconds(2);

 digitalWrite(trigPin, HIGH);
 delayMicroseconds(10);

 digitalWrite(trigPin, LOW);
 duration = pulseIn(echoPin, HIGH);

 //Calculate the distance (in cm) based on the speed of sound.
 distance = duration/58.2;

 if (distance >= maximumRange || distance <= minimumRange){
 /* Send a negative number to computer and Turn LED ON
 to indicate "out of range" */
 Serial.println("-1");
 digitalWrite(LEDPin, HIGH);
 }
 else {
 /* Send the distance to the computer using Serial protocol, and
 turn LED OFF to indicate successful reading. */
 Serial.println(distance);
 digitalWrite(LEDPin, LOW);
 }

 //Delay 50ms before next reading.
 delay(50);
}

Processing Code:
You can download the Processing IDE from this site.

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128

/* The following Processing Sketch was created by ScottC on
 the 10 Nov 2012 : http://arduinobasics.blogspot.com/

 Inspired by this Processing sketch by Daniel Shiffman:
 http://processing.org/learning/basics/sinewave.html

*/
import processing.serial.*;


int numOfShapes = 60; // Number of squares to display on screen
int shapeSpeed = 2; // Speed at which the shapes move to new position
 // 2 = Fastest, Larger numbers are slower

//Global Variables
Square[] mySquares = new Square[numOfShapes];
int shapeSize, distance;
String comPortString;
Serial myPort;

/* -----------------------Setup ---------------------------*/
void setup(){
 size(displayWidth,displayHeight); //Use entire screen size.
 smooth(); // draws all shapes with smooth edges.

 /* Calculate the size of the squares and initialise the Squares array */
 shapeSize = (width/numOfShapes);
 for(int i = 0; i<numOfShapes; i++){
 mySquares[i]=new Square(int(shapeSize*i),height-40);
 }

 /*Open the serial port for communication with the Arduino
 Make sure the COM port is correct - I am using COM port 8 */
 myPort = new Serial(this, "COM8", 9600);
 myPort.bufferUntil('\n'); // Trigger a SerialEvent on new line
}

/* ------------------------Draw -----------------------------*/
void draw(){
 background(0); //Make the background BLACK
 delay(50); //Delay used to refresh screen
 drawSquares(); //Draw the pattern of squares
}


/* ---------------------serialEvent ---------------------------*/
void serialEvent(Serial cPort){
 comPortString = cPort.readStringUntil('\n');
 if(comPortString != null) {
 comPortString=trim(comPortString);

 /* Use the distance received by the Arduino to modify the y position
 of the first square (others will follow). Should match the
 code settings on the Arduino. In this case 200 is the maximum
 distance expected. The distance is then mapped to a value
 between 1 and the height of your screen */
 distance = int(map(Integer.parseInt(comPortString),1,200,1,height));
 if(distance<0){
 /*If computer receives a negative number (-1), then the
 sensor is reporting an "out of range" error. Convert all
 of these to a distance of 0. */
 distance = 0;
 }
 }
}


/* ---------------------drawSquares ---------------------------*/
void drawSquares(){
 int oldY, newY, targetY, redVal, blueVal;

 /* Set the Y position of the 1st square based on
 sensor value received */
 mySquares[0].setY((height-shapeSize)-distance);

 /* Update the position and colour of each of the squares */
 for(int i = numOfShapes-1; i>0; i--){
 /* Use the previous square's position as a target */
 targetY=mySquares[i-1].getY();
 oldY=mySquares[i].getY();

 if(abs(oldY-targetY)<2){
 newY=targetY; //This helps to line them up
 }else{
 //calculate the new position of the square
 newY=oldY-((oldY-targetY)/shapeSpeed);
 }
 //Set the new position of the square
 mySquares[i].setY(newY);

 /*Calculate the colour of the square based on its
 position on the screen */
 blueVal = int(map(newY,0,height,0,255));
 redVal = 255-blueVal;
 fill(redVal,0,blueVal);

 /* Draw the square on the screen */
 rect(mySquares[i].getX(), mySquares[i].getY(),shapeSize,shapeSize);
 }
}

/* ---------------------sketchFullScreen---------------------------*/
// This puts processing into Full Screen Mode
boolean sketchFullScreen() {
 return true;
}

/* ---------------------CLASS: Square ---------------------------*/
class Square{
 int xPosition, yPosition;

 Square(int xPos, int yPos){
 xPosition = xPos;
 yPosition = yPos;
 }

 int getX(){
 return xPosition;
 }

 int getY(){
 return yPosition;
 }

 void setY(int yPos){
 yPosition = yPos;
 }
}

However, if you do not have a google profile...
Feel free to share this page with your friends in any way you see fit.

# data[].attributes.attachment_link.description
The HC-SR04 Ultrasonic Sensor is a very affordable proximity/distance sensor that has been used mainly for object avoidance in various robotics projects . It essentially gives your Arduino eyes / spacial awareness and can prevent your robot from crashing or falling off a table.

# data[].attributes.body
A video demonstration of using the Sharp IR sensor to control the speed of playback of percussion samples in Pure Data.
I'd like to explore building a 'ring' of these sensors to offer control over a variety of parameters in a single instrument.

# data[].attributes.attachment_link.title
Infrared Sensor / Arduino / Pure Data Exploration

# data[].attributes.attachment_link.description
Exploring using an infrared sensor and arduino to control rate of playback of percussion samples in pure data.

# data[].attributes.body
This library certainly improves the readings obtained from the Sharp IR sensor.
Not sure on the definition of one of the arguments it expects though - seems like an 'error margin' given as a percentage - 1% seems to give best results, although not a huge difference between 1% and 99% in the tests I conducted.
The sketch I am using for this is below.
I'm also using an [average] and a [Line] object within Pure Data to further 'smooth' my readings.

# data[].attributes.body
An experiment with a single photo-resistor, as per the bildr tutorial.
It seemed the resistor was only really useful when working with dramatic changes in light level - from very dark, to very bright.
Would be good to find a more sensitive resistor that might allow for greater precision/subtlety in performance.

# data[].attributes.attachment_link.description
Initial experiments using a photo-resistor and arduino to control playback of a sample in pure data.

# data[].attributes.body
This site has a useful tool for calculating the value of resistors using the coloured stripes.
(Other websites I found didn't seem to match with the resistors I'd purchased from Maplins.)

# data[].attributes.attachment_link.keywords[]
5 band resistor color code calculator and chart

# data[].attributes.attachment_link.title
5 Band Resistor Color Code Calculator and Chart | DigiKey Electronics

# data[].attributes.attachment_link.description
The Resistor Color Code Calculator decodes and identifies a value and tolerance of 5 band wire wound resistors. More online conversion calculators at Digi-Key.

# data[].attributes.body
This seemed like a promising library for outputting my data as MIDI, however, doesn't seem to be compatible with the arduino uno board I have....

(Would need to look for a board with 'native usb' capabilities - https://learn.sparkfun.com/tutorials/arduino-comparison-guide)

# data[].attributes.attachment_link.description
These library allows any microcontroller with native USB capabilities (atmega32u4 based boards or ARM boards) to appear as a MIDI peripheral over USB to a connected computer.

# data[].attributes.body
[comport] is an external object for Pure Data which allows data to be read from a serial port/device.
Will read values from 'Serial.write()' in arduino sketch.

# data[].attributes.attachment_link.description
Pd object for reading and writing to serial ports

# data[].attributes.attachment_link.readable_text
The LDR (light dependent resistor) also know as the Photo-resistor (and many other things) is supposed to be day 1 of electronics. But I guess I missed the note because I never used one with my arduino maybe until now. So I guess I'm weird. But the LDR is super cheap, probably one of the easiest parts to find / use, and certainly has to have the simplest code. You can find these at any electronics store ever I imagine, or do what I did and add a few to your next sparkfun order.
If you need precise light measurement check out the TEMT6000 or the TSL230R
The LDR / Photo-resistor is basically a very simple light sensor that changes its resistance with light, lowering with more light. You can find these used in everything from the furby to automatic night lights and things like that. The LDR isn't very precise, so you cant get a quantitative LUX reading or anything like that. But it is good enough to tell the difference between light and shadow, or know if the light in your room is on/off. So if you just need to know if the light in the room has changed, or someone walked by (casting a shadow) this is your part.

Hooking it up, and why

The LDR changes its resistance with light so we can measure that change using one of the Arduino's analog pins. But to do that we need a fixed resistor (not changing) that we can use for that comparison (We are using a 10K resistor). This is called a voltage divider and divides the 5v between the LDR and the resistor. Then we measure how much voltage is on the LDR using the analog read on your arduino, and we have our reading. The amount of that 5V that each part gets is proportional to its resistance.

With the arduino analogRead, at 5V (its max) it would read 1023, and at 0v it read 0.

So if the the LDR and the resistor have the same resistance, the 5V is split evenly (2.5V), to each part. (analogRead of 512)

But if the LDR is hit with a ton of light and is reading only 1K of resistance, the 10K resistor is going to soak up 10 times as much of that 5V. So the LDR would only get .45V (analogRead of 92).

And if it is in a dark room, the LDR may be 40K or resistance, so the LDR will soak up 4 times as much of that 5V as the 10K resistor. So the LDR would get 4V (analogRead of 818).

Code

The arduino code for this just could not be easier. We are adding some serial prints and delays to it just so you can easily see the readings, but they dont need to be there if you dont need them.

int LDR_Pin = A0; //analog pin 0

void setup(){
Serial.begin(9600);
}

void loop(){
int LDRReading = analogRead(LDR_Pin);

Serial.println(LDRReading);
delay(250); //just here to slow down the output for easier reading
}

# data[].attributes.attachment_link.title
bildr " Simple Light Reading With LDR + Arduino

# data[].attributes.attachment_link.description
The LDR (light dependent resistor) also know as the Photo-resistor (and many other things) is supposed to be day 1 of electronics. But I guess I missed the note because I never used one with my arduino maybe until now. So I guess I'm weird.

# data[].attributes.body
When using the Sharp IR sensor,
Will likely need this library to improve the readings captured.
(Sensor on it's own gives pretty erratic readings!)

# data[].attributes.attachment_link.description
I have experienced that Sharp IR sensors do not deliver steady readings. To my experience 12% of the readings give values with an error up to 42% over the actual distance. What this library does is to take a bunch of measurements and calculate a mean distance, taking into account only the measurements that do not differ much from one another.