Skip to content

Instantly share code, notes, and snippets.

Created September 27, 2017 18:26
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save jgiovanni/6b80888629e3cec811a2fc7fab7e9217 to your computer and use it in GitHub Desktop.
* Course: Ateliyer 1: Discovery - DGIF-2004
* Prototype: TetherPad
* Group Members: Johan Seaton, Sanmeet Chahil, Jerez Bain
* This code is used to allow the arduino to communicat with Ableton Live using the downloadable Connection Kit and Max for Live
#include <Firmata.h>
byte analogPin = 0;
void analogWriteCallback(byte pin, int value)
// Because PMW pins can be used to replicate analog behavior, check if the pin used is PMW
if (IS_PIN_PWM(pin)) {
analogWrite(PIN_TO_PWM(pin), value);
void setup()
// Setup Firmata Firmware
// Attach event callback 'analogWriteCallback', to changes in 'ANALOG_MESSAGE'
Firmata.attach(ANALOG_MESSAGE, analogWriteCallback);
// Similar to Serial.begin, except for Firmata
void loop()
// Continue to process inputs while firmata is available
while (Firmata.available()) {
// do one analogRead per loop, so if PC/Mac is sending a lot of
// analog write messages, we will only delay 1 analogRead
Firmata.sendAnalog(analogPin, analogRead(analogPin));
analogPin = analogPin + 1;
// in each loop the analogPin value increments, sending values one at a time.
// if the value exceeds the total number of available pins, start at 0 again
if (analogPin >= TOTAL_ANALOG_PINS) analogPin = 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment