Firmata and Arduino2Max

For a lot of projects you might just want to use the arduino just as an interface to different applications, like max,pd,flash,vvvv,processing etc, and not worry about the programming of the arduino.

Firmata does just that: giving you control over the outputs and reading the inputs, and then there are different implementations for different applications. All you need to do is to upload the firmata firmware on the arduino as you would with any sketch, and then use the implementation for your application (maxuino for max, pduino for pd etc).

If you just want to use the Arduino as a sensor interface for max, you could take a look at Arduino2Max.


the most common resistor values

Just as a reminder of the color codes and values of the resistors we have used in the workshop:


snapshots from the resistulator widget for osx.

Connecting a variable resistor to the arduino, analog in


(Sketch based on illustrations from the books “Physical Computing” and “Making things talk”)

Most variable resistors have two connectors (if they have three they should most likely be connected like the potentiometer).

One goes to the +5v output on the arduino, the other one goes both to the analog input of the arduino and through a fixed resistor (the value should be related to the value of the variable resistor, but I usually try with a 10k resistor first) to ground.

You can use the same example as for the previous post.

Connecting a potentiometer to the arduino, analog in


(sketch based on illustrations in the books “Physical Computing” and “Making things talk”.)

Here is a simple arduino code example illustrating both Analog in and out:

int potVar = 0;

void setup() {
pinMode(11, OUTPUT);

void loop() {
//read the voltage on the potentiometer:
potVar = analogRead(0);
//print the value out:
Serial.println(potVar, DEC);
//slight pause
//dim the LED. since the resolution of the input is 10bit and the output(1024)
//is only 8bit (255) we need to divide potVar by 4 to get the right range

Digital input to the arduino


(sketch based on illustrations from Physical Computing and Making Things Talk)

The simplest code to get a reading from a switch is the Button example from the arduino tutorials.

Here is a modification of this code illustrating the principle of edge detection, just sending out a value whenever the state of the switch changes (and not everytime the arduino checks the state of the input pin). This would be useful for instance if used together with´s applescript proxy

int ledPin = 13; // choose the pin for the LED
int inputPin = 2; // choose the input pin (for a pushbutton)
int val = 0; // variable for reading the pin status
int prevState = 0;

void setup() {
pinMode(ledPin, OUTPUT); // declare LED as output
pinMode(inputPin, INPUT); // declare pushbutton as input

void loop(){
prevState = val;
val = digitalRead(inputPin); // read input value
if (val != prevState) {
if (val == HIGH) { // check if the input is HIGH
digitalWrite(ledPin, HIGH);
} else {
digitalWrite(ledPin, LOW);

And finally a simple example to show how you could work with multiple input:

int inputPin1 = 2;
int inputPin2 = 3;

void setup()
pinMode(inputPin1, INPUT);
pinMode(inputPin2, INPUT);

void loop()

piezo as sensor


Use the code from the “knock” example in the arduino tutorials

The interesting thing in this example is how to use an analog input and look for a treshold value that triggers some action, so basically a switch which can be “tuned”.

 Look here for examples on how to use the piezo element to play sounds.

Where to get things (when based in the nordic countries)

The cheapest and easiest place to get the arduino boards is electrokit in Sweden which has a selection of other things as well.

Another alternative is PCB Europe which also has other arduino related products.

For electrical components the most obvious choice would be ELFA or Farnell.

For the most basic components and for tools, Clas Ohlson is a possibillity.

My overall favourite shop is the American based Sparkfun which has a good selection of things for the arduino, sensors, add-ons, components etc. A thing to remember though is the shipping costs and custom expenses.

Mouser electronics has very good shipping rates internationally, as low as 25 usd-35usd with fedex priority, and a good selection.

If you want to get the parallax sensors you dont want to order them from their website as they have a ridiculously high shipping rate to Europe. I found a swedish webshop lawicel which carry most of the parallax products.