vidiotsquad

arduino and midi input

February 22nd, 2009

i’ve been using the arduino for midi input and output for a while now, mainly using kuk’s input method, output is easy enough though. midi input had me stumped for a while, but he found adding 100k resistor to the base of the phototransistor of the optoisolator created a stable response which sorted it out.

theres alot you can do with variations of his code, and many people have used the circuit to build midi>cv convertors for analogue synths, but at the moment i’m mostly interested in building a clock source for analouge/digital sequencers so i can run them straight from the output of my HR-16 or tr-505 without the need for a computer based midi sequencer. the basic idea is to receive a midi clock byte and advance the count of a 4 bit binary output from the arduino to advance the steps of a multiplexer ic based sequencer.

midi clocks output 24 pulses per quarter note, so this needs dividing down to get the step response you need. the ever useful and highly inspiring code from littlescale comes in handy here!

more soon.

IR Sensor stuff

October 31st, 2008

Guilherm asked to see a schematic for the IR sensors, so i’ve knocked a quick one up in Eagle for anyone else who’s interested. In the circuit, in its most basic form, the IR led is always on, connected to 5volts with a suitable resistor for the IR diode you are using in relation to the power supply.The IR sensor is connected in the same way, i found a 10k resistor worked in this case, but play arround with different values as it will affect is performance.

Both the IR led and sonsor should be connected to ground.

Between the resistor and the sensor, a jumper wire is connected to what ever you are using to read the sensor. This can be an analogue comparitor connected to an led circuit, or in my case in the videos below. an analogue input on the Arduino, either directly or via a demultiplexor.

ir-sensor.png

Simple arduino code to read sensor and send to serial/USB.

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

void loop()
{
Serial.println(analogRead(5));
delay(20);
}

Simple Arduino code to read sensor and switch on an LED connected to Pin 8:

//works between 200 and 300 threshold with 5mm perspex.
//direct light triggers sensor and sensor only works with perspex when inverted, trigger = off.
int ledPin = 8;      // LED connected to digital pin 9
int analogPin = 5;   // potentiometer connected to analog pin 3
int threshold = 300;

void setup()
{
pinMode(ledPin, OUTPUT);   // sets the pin as output
Serial.begin(9600);
}

void loop()
{

if (analogRead(analogPin) < threshold) {
digitalWrite(ledPin, LOW);  // turn LED ON
} else {
digitalWrite(ledPin, HIGH);
Serial.println(analogRead(analogPin));
}

}

In this code, the led is switched on when the sensor value exceeds a certain reading, but could be adapted to dim an LED using PWM very easily. At the moment i have 16 sensors connected via two 4051 demultiplexor IC’s, connected to two analogue inputs on the arduino, and several digital pins to control which pins are read on the 4051. The Arduino then pumps the sensor readings out to a TI 5940 led controller as PWM signals to control the LED’s.

Hope this helps  Guilherm!

Proudly powered by WordPress.