Introduction: Sugarcube MIDI Controller

This project is a portable, Arduino-powered, grid-based MIDI controller that boots up into a variety of apps to do lots of things with sound. It has 16 backlit buttons, used as both inputs and outputs to give the controller some visual feedback. 2 potentiometers give analog control, depending on the app the pots are assigned to tempo, MIDI velocity, pitch, and scrolling (making the avaible grid space larger than 4x4). An x/y accelerometer and an x/y gyroscope add some playful, gestural control to the device; most of the apps implement a "shake to erase" control and several respond to tilt in various ways. It boots up into 7 different apps (described below), though it has the potential to boot up into 16 total. This device is primarily a MIDI controller, but I've also written an app that allows you to pull the button and analog data into MaxMSP and to control audio.

This controller was inspired by both the monome and tenori-on. When I was in college, I built a large touchscreen display, based on the Arduinome monome-Arduino clone schematics and code, that worked with all the open source monome applications written in MaxMSP. There are a ton of people building their own monome-type devices using these buttons from Sparkfun and the Arduinome code, as well as a few variations on the theme. With this project, I was interested in making a device that was a little more self-contained and relatively cheap to make (lots of buttons = lots of $). In keeping more with the concept of the tenori-on, this controller does all its app processing itself, it does not rely on a computer to process button presses/analog controls into MIDI. This means you can plug it directly into a synth or any device that understands MIDI and you're good to go, no computer required. It runs off a beefy LiPo battery that keeps it running for days on a charge, so it's fairly portable as well. In keeping with the monome side of things, it's totally open source and can be adapted to your particular audio setup/needs. All the Arduino code is up on github (click the cloud-shaped button to download), along with a MaxMSP patch that decodes data from the controller into something usable in Max.

An overview of the apps I've written so far:

Pixel Tilt - One pixel moves across a 2D keyboard with tilt, triggering MIDI as it moves. Control velocity and basenote with pots.

Flin - Music Box app based on monome. Speed and velocity of notes controlled by y tilt. Paging across 16 "lanes" with pot. Shake to erase.

Serial Communication with MaxMSP - Pull data from buttons and analog controls into MaxMSP and use Max to send LED states. Supports 5 bit analog controls for x/y accelerometer and 2 pots. This is great if you want to run audio processing applications with the controller. Download SerialDemo app (SerialDemo.maxpat, included with the Arduino files, click the cloud-shaped button here) to parse data in Max. Beat slicer (shown above) app is included with the Arduino files as well.

Arpeggiator - Plays a two, three, or four note arpeggio, similar to this app I wrote for monome. One pot controls the speed of the arpeggio, another controls velocity. Notes within the arpeggio can be shifted up or down by one semitone via button controls. The whole arpeggio is transposed via x tilt. Press the leftmost note in the arpeggio to play the notes in ascending order, press the rightmost note in the arpeggio to play the notes in descending order, and press a middle note in the arpeggio to play the notes in a random order. Shake to erase.

Boiing - Bouncing pixels that generate polyrhythms, based on this tenori-on app. Bounce direction based on y tilt. Speed and MIDI velocity (loudness) controlled by pots. Shake to erase.

Step Sequencer - Four note 16 step sequencer. Pots control tempo and paging across sequence. Shake to erase.

MIDI Keyboard - Simple MIDI keypad. Control velocity and basenote with pots, pitchbend with x tilt.

Parts List:

SPARKFUN:
(1x) Button Pad 4x4 - LED Compatible Sparkfun COM-07835
(1x) Button Pad 4x4 - Breakout PCB Sparkfun COM-08033
(1x) Arduino Uno Sparkfun DEV-11021
(1x) Accelerometer/Gyro 5 Degrees of Freedom Sparkfun SEN-11072

I put a 3-axis accelerometer and 2 axis gyroscope in this controller to give it some gestural control, but so far I haven't actually used the gyro in any apps, and I've only got the x and y axis of the accelerometer wired up. That means you could sub in a simpler/cheaper part like this. Update: this part is no longer available and I'm having a hard time finding an analog gyro to replace it. This analog accelerometer board will work, and as I said before, I haven't actually implemented any apps with the gyro yet, so it's not really necessary. the wiring is a little different for the new accelerometer, but if you connect x, y, z, gnd the way I've described in the rest of the schematics, and connect the 5V from the Arduino to the accelerometer's Vin, it should work the same.

DIGIKEY:
(16x) White 5mm LED (3mm is fine too) Digikey C513A-WSN-CV0Y0151-ND
(2x) 74HC595 shift register Digikey 296-1600-5-ND
(1x) 74HC165 shift register Digikey 296-8251-5-ND
(3x) 16 pin IC socket Digikey AE9992-ND

(16x) 1N4148 Diode Digikey 1N4148FS-ND
(4x) current limiting resistors (value will depend on LEDs, sample calculation included in step 5)
(4x) 10kOhm 1/4watt resistors Digikey CF14JT10K0CT-ND
(1x) 220Ohm 1/4watt resistor Digikey CF14JT220RCT-ND
(1x) 5-Pin MIDI Jack Digikey CP-7050-ND (optional - explained in step 27)
(1x) USB type B female jack Digikey 732-2734-ND (optional - explained in step 27)
(2x) 10kOhm linear taper potentiometer Digikey 987-1308-ND

(1x) Size N Panel-Mount Coaxial DC Power Jack with Switch Radioshack 274-1573 Update Digikey CP-002AHPJCT-ND this part may look different than the one pictured, check the datasheet/use a multimeter to be sure connection are correct.

(1x) SPST Toggle Switch Digikey 360-3289-ND

(1x) Size N Coaxial Power Plug Digikey CP3-1000-ND

JAMECO:
(1x) 16 conductor ribbon cable Jameco 28RC16-10VP
(1x) 16 pin right angle connector Jameco 746285-3
(6x) male header pins Jameco 103393

AMAZON:

(1x) Midi Cable Amazon (optional - explained in step 27)

(1x) Li-Ion 7.4V Tenergy 2200mAh Rechargeable Battery module with PCB Amazon
(1x) Tenergy Universal Smart Charger for Li-Ion/Polymer battery Pack (3.7V-14.8V 1-4 cells) Amazon
(1x) MIDI to USB cable Amazon (optional - explained in step 27)

MANY SUPPLIERS:
(2x) Knobs - the knobs I got are out of stock (from newark) as long as it fits a 0.25"/6.35mm shaft it will work, pick something you like:

https://www.tubesandmore.com/products/knobs

http://amzn.to/1RXew6a

ADDITIONAL MATERIALS:
22 Gauge Wire, various colors Jameco #9313-0-R
electrical tape Radioshack 64-2373
wire cutters
wire strippers
solder
wood/acrylic/project enclosure (I used this 6"x6"x2" bamboo box The Container Store)
glue/epoxy
double sided foam tape Amazon

Step 1: Schematic and Overview

All schematics for this project are shown above. Detailed overviews of the 74HC595, 74HC165, and power connections are given later in this Instructable. All the Arduino pin connections are listed below:

Analog

0 - Gyroscope Y (Y4.5)
1 - Potentiometer 1
2 - Gyroscope X (X4.5)
3 - Accelerometer Y (YAcc)
4 - Accelerometer X (XAcc)
5 - Potentiometer 2

Digital

0 - serial in - this must remain unconnected
1 - serial out - this is hooked up to the MIDI output
2 - 74HC165 data pin (Q7)
3 - 74HC165 clock pin (CP)
4 - 74HC165 latch pin (PL)
5 - 74HC595 clock pin (SH_CP)
6 - 74HC595 latch pin (ST_CP)
7 - 74HC595 data pin (DS)

no connections to digital pins 8-13

Step 2: Solder LEDs to Sparkfun PCB

Thread the leads of 16 LEDs (5mm or 3mm are fine, I used 5mm) through LED holes in the Sparkfun PCB. These boards are compatible with 4-lead RGB LEDs, so there are four available holes on each button pad. You can use the two center holes for single color LEDs (see figure 3). Be sure that the flat edge of the LED (the cathode) lines up with the flat marking on the PCB.

Solder the LED leads and cut away the excess wire.

Step 3: Solder Diodes to Sparkfun PCB

Solder 16 diodes to Sparkfun PCB. Be sure to line up black marking on diode (cathode) with the stripe on the PCB.

Step 4: Ribbon Cable

Cut about 1ft of 16 conductor ribbon cable. Separate and strip the ends of all 16 wires on one side and solder to Sparkfun PCB. The following list gives all the colored conductors in order with the name of the PCB hole they should be soldered to, if you do this correctly none of the wires should cross. Note that since I'm only using a single color LED, I'll wire up only the "blue" anode.

Connections:

(one side of ribbon cable)
Brown to SWT-GND1
Red to LED-GND1
Orange to SWT-GND2
Yellow to LED-GND2
Green to SWT-GND3
Blue to LED-GND3
Purple to SWT-GND4
Grey to LED-GND4
White to BLUE4
Black to SWITCH4
Brown to BLUE3
Red to SWITCH3
Orange to BLUE2
Yellow to SWITCH2
Green to BLUE1
Blue to SWITCH1
(other side of ribbon cable)

Step 5: Clamp Socket

Use a bench vice to clamp the16 pin socket on the ribbon cable. If you do not have a bench vice do not use pliers do this, you will clamp the socket on sideways and mess up the connections. You're better off using a hammer to tap the clamp shut, just make sure you are always applying pressure evenly across the socket.

Be sure the clamp the socket on the ribbon cable in the same orientation indicated in the images above.

Step 6: Multiplexing With Arduino and 74HC595

Two 74HC595s (wired in parallel) will be driving all the LEDs in the project as well as providing power to all of the buttons. The 74HC595 is an 8 bit serial in parallel out shift register. I've written a detailed tutorial about multiplexing with the 74HC595, and you can find more info about this chip on its datasheet. Please note that the 74HC595 drawn in the schematic is not a pin diagram, I have rearranged the order of the pins to make the circuit diagram more clear. The pin diagram for the chip is shown in fig 4.

The 74HC595 has the following pins (the technical name may be one of several things depending on which data sheet you are reading):

Position Common Name Technical Name

1 parallel output 2 QB or Q1
2 parallel output 3 QC or Q2
3 parallel output 4 QD or Q3
4 parallel output 5 QE or Q4
5 parallel output 6 QF or Q5
6 parallel output 7 QG or Q6
7 parallel output 8 QH or Q7
8 ground GND
9 serial data output QH' or Q7' or Q7S
10 master reset (active low) MR(with a line on top) or SRCLR(with a line on top)
11 clock pin SH_CP or SRCLK
12 latch pin ST_CP or RCLK
13 output enable (active low) OE(with a line on top)
14 data pin DS or SER
15 parallel output 1 QA or Q0
16 5 volts supply VCC

The connections between the 74HC595 and the sparkfun board are shown in the schematic and repeated below:

74HC595 / Sparkfun Breakout Board

Q0 to BLUE 4 and SWITCH 4
Q1 to BLUE 3 and SWITCH 3
Q2 to BLUE 2 and SWITCH 2
Q3 to BLUE 1 and SWITCH 1
Q4 to LED GND 4 (via current limiting resistor)
Q5 to LED GND 3 (via current limiting resistor)
Q6 to LED GND 2 (via current limiting resistor)
Q7 to LED GND 1 (via current limiting resistor)

The remaining pins have the following connections to the Arduino (also shown in schematic):

74HC595 / Arduino

Vcc to Arduino 5V
GND to Arduino GND
DS to Digital Pin 7
OE(line on top) to GND
ST_CP to Digital Pin 6
SH_CP to Digital Pin 5
MR(line on top) to Arduino 5V
Q7' - no connection

Step 7: Header Pins

Solder two rows of eight header pins to the protoboard. This is where the ribbon cable socket will attach to the board.

Step 8: Current Limiting Resistors

The 74HC595 will be driving the LEDs in the sparkfun board. However, this chip only outputs 0 or 5V and it can output as much as 70mA. This means we must use current limiting resistors to prevent damaging the LEDs.

From the specs of the LEDs I used:
max forward current: 30mA
forward voltage: 3.2V

Calculate the resistance needed to achieve these max ratings from V = IR:
resistance = (5V-3.2V) / (0.03A)
= 60 ohms

I used 68 ohm resistors so that I was not running at the absolute maximum, but also ensuring that I wouldn't lose too much brightness. (I made a mistake a grabbed the 100KOhm resistors when I made this project, I fixed it later, but the stripes of 100Ohm resistors should be blue, grey, black, gold, ignore the colors in the images).

These are the sample calculations for the specific LEDs I used, you'll need to do you own calculations based on the specs of your LEDs. If you are unsure of what to do, use 220ohm or higher resistors; using too much resistance will make the LEDs less bright, but they will not be damaged.

Solder four resistors to the protoboard as shown in the images. Connect the leads of the resistors to their adjacent header pins with solder (figure 2).

Step 9: 74HC595 Socket

Solder an 8-pin socket to the protoboard as shown in the images above.

Step 10: Connections to LEDs

As shown in figure 6, the output pins (Q0-Q7) are located on pins 1-7 and 15. This image was taken from the datasheet of the 74HC595. Connect the resistors to pins 4-7 with jumper wires as shown in figures 1 and 2. Connect pins 1-3 and 15 to the header pins according to the schematic (note the wiring in the image is incorrect, but the schematic is correct). The pins connections to the 74HC595 should be as follows:

Pin 15 - Blue 4
Pin 1 - Blue 3
Pin 2 - Blue 2
Pin 3 - Blue 1
Pin 4 - LED GND 4
Pin 5 - LED GND 3
Pin 6 - LED GND 2
Pin 7 - LED GND 1

Be sure to get these pin connections correct- do this part slowly and refer to the schematic often.

Make sure to electrically join all these connections with solder on the underside of the board (figs 2 and 4)

Step 11: Add Second 74HC595: Part 1

Each 74HC595 can only source 70mA at a time for all its pins. With the 100ohm current limiting resistors, if all 4 LEDs in a row are on at the same time (with multiplexing this is the max number of LEDs that can possibly be on at the same time), they will each draw about 18mA which puts the current requirements slightly above the 70mA maximum rating. I'll be drawing additional current from pins Q0-Q7 to multiplex the buttons (in later steps). An easy solution to this problem is to add another 74HC595 to the circuit, it will be wired parallel to the current 74HC595 (see schematic). This will give us additional 70mA to draw from on all 8 pins.

Add another 16 pin socket to the protoboard as shown in the images.

Step 12: Add Second 74HC595: Part 2

Wire pins 1-7 and 15 of the sockets to each other (see note on schematic). These pins correspond to all eight outputs of the 74HC595s.

Step 13: Add Second 74HC595: Part 3

Connect pin 8 (ground) and pin 16 (5V) of the sockets together (see image note on schematic).

Step 14: Add Second 74HC595: Part 4

Connect pins 11, 12, and 14 of the sockets to each other. These correspond to the clock, latch, and data pins of the 74HC595s.

Step 15: Add Second 74HC595: Part 4

Wire pin 10 to 5V (pin 16) and pin 13 to ground (pin 8). Pin 10 (MR) should be high and pin 13 (OE) should be low in order to send data to the output pins (Q0-Q7).

Step 16: Header Pins

Solder header pins to the perfboard so that an Arduino Uno can snap fit onto it. Be careful of the odd pin spacing between digital pins 7 and 8, I've designed this project so that connecting to pin 8-13 is not necessary, it's probably best to omit header pins for Arduino pins 0-13 so that things snap together easier (see image note).

Step 17: Connect 74HC595 to Arduino

Connect three 74HC595 data pins to Arduino digital pins 5, 6, and 7. Connect ground and 5V to Arduino corresponding power pins.

Pin connections:

74HC595 / Arduino

data pin (pin 14) to digital pin 7
latch pin (pin 12) to digital pin 6
clock pin (pin 11) to digital pin 5

Step 18: Test LEDs

Upload the code below onto the Arduino and test to see if LEDs are wired correctly. Insert two 74HC595s into the empty sockets, plug the button pcb into its socket, and connect the arduino to the protoboard (fig 1). You should see each LED light up one at a time, this loop will continue repeating forever (see video below). If this is not working, double check the connections in the previous steps and check all your connections for continuity. Do not continue onto the next steps until you get the LEDs working.

For more information on the 74HC595 and shiftOut, see fig 2, the datasheet, and the arduino reference page.
//LED TEST w/ 74HC595
//by Amanda Ghassaei 2012

/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
*/

//this firmware lights up each led one by one

//pin connections
int latchPin = 6;
int clockPin = 5;
int dataPin = 7;

//looping variables
byte i;
byte j;

//storage variable
byte dataToSend;

void setup() {
  pinMode(latchPin,OUTPUT);
  pinMode(clockPin,OUTPUT);
  pinMode(dataPin,OUTPUT);
}

void loop() {
  for (i=0;i<4;i++){
    for (j=0;j<4;j++){
      
      dataToSend = (1 << (i+4)) | (15 & ~(1 << j));//preprare byte to send to 74HC595
      
      // setlatch pin low so the LEDs don't change while sending in bits
      digitalWrite(latchPin, LOW);
      // shift out the bits at dataToSend
      shiftOut(dataPin, clockPin, LSBFIRST, dataToSend);
      //set latch pin high so the LEDs will light up
      digitalWrite(latchPin, HIGH);
      
      delay(500);//wait
    }
  }
}

Step 19: Multiplexing With Arduino and 74HC165

The 74HC595 can only do parallel output, so I used a 74HC165 to measure the state of the buttons via 4 current limiting resistors and send this information to the Arduino. More info about the chip can be found on its datasheet. Note in fig 2 that the 595 chips from the previous steps will be providing power to the buttons (as they are doing for the LEDs).

The 74HC165 has the following pins (the technical name may slightly different depending on which data sheet you are reading):

Position / Common Name / Technical Name

1 / latch pin (active low) / PL(with a line on top)
2 / clock pin / CP
3 / parallel input 4 / D4
4 / parallel input 5 / D5
5 / parallel input 6 / D6
6 / parallel input 7 / D7
7 / inverse serial output / Q7(with a line on top)
8 / ground / GND
9 / serial output (data pin) / Q7
10 / serial input / DS
11 / parallel input 0 / D0
12 / parallel input 1 / D1
13 / parallel input 2 / D2
14 / parallel input 3 / D3
15 / clock enable input (active low) / CE(with a line on top)
16 / 5 volts supply / VCC

The connections between the 74HC165 and the Sparkfun board are shown in the schematic and repeated below:

74HC165 -> Sparkfun Breakout Board

D0 to SWITCH GND 4
D1 to SWITCH GND 3
D2 to SWITCH GND 2
D3 to SWITCH GND 1

(note that the 165 pins should also have a connection through a resistor to ground - see schematic)

The remaining pins have the following connections to the Arduino (also shown in schematic):

74HC165 -> Arduino

Vcc to Arduino 5V
GND to Arduino GND
CE(line on top) to Arduino GND
DS to Arduino GND
Q7 to Digital Pin 2
Q7(line on top) - no connection
PL(line on top) to Digital Pin 4
CP to Digital Pin 3

Step 20: 74HC165: Part 1

Solder a third 16 pin socket to the protoboard, this will be for the 74HC165. Connect 5V to pin 16 and ground to pin 8.

Step 21: 74HC165: Part 2 Pull Down Resistors

I used resistors in series with the buttons to pull D0-D3 of the 165 chip down to ground while the buttons are not pressed - this is called a "pull down resistor". Solder four 10kOhm resistors to the pins adjacent to the header pins (see fig 1). Connect four wires from the 74HC165 inputs D0-3 (pins 11-14) to the space between the male header pins and the 10k resistors as indicated in fig 3 and in the schematic (also see yellow wires in fig 2). Drag solder between the header pins, the wires to the 165 chip, and the resistors to connect them (see fig 3). Connect the other side of all four resistors to each other and to Arduino ground (again see fig 3 and the schematic).

We'll be powering the buttons with the same supply that is powering the LEDs - the 595 chips. Drag solder between the header pins that connect to the LED-BLUE (1-4) on the sparkfun board to the header pins that connect to SWITCH (1-4) on the sparkfun board (see note on fig 3 and 5).

Step 22: 74HC165: Part 3

Connect the data pins of the 74HC165 to the Arduino (brown wires)
Pin connections (also shown in schematic):

74HC165 / Arduino

PL(line on top) (pin 1) to digital pin D4
CP (pin 2) to digital pin D3
Q7 (pin 9) to digital pin D2

Step 23: 74HC165: Part 4

Connect ground to pins 15 (CE with line on top) and 10 (DS) of the 74HC165.

Step 24: Test Buttons

Upload the following code onto the Arduino. If everything is wired correctly each button will light up while pressed. If you're noticing that some buttons are not as responsive try cleaning the conductive rings and the traces on the pcb with water and drying thoroughly, this solved some response problems for me.
//BUTTON TEST w/ 74HC595 and 74HC165
//by Amanda Ghassaei 2012

/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
*/

//this firmware will cause the buttons to light up momentarily while they are pressed.

//pin connections
int ledLatchPin = 6;
int ledClockPin = 5;
int ledDataPin = 7;
int buttonLatchPin = 4;
int buttonClockPin = 3;
int buttonDataPin = 2;

//looping variables
byte i;
byte j;
byte k;

//storage for led states, 4 bytes
byte ledData[] = {0, 0, 0, 0};
//storage for buttons, 4 bytes
byte buttonCurrent[] = {0,0,0,0};
byte buttonLast[] = {0,0,0,0};
byte buttonEvent[] = {0,0,0,0};
byte buttonState[] = {0,0,0,0};
//button debounce counter- 16 bytes
byte buttonDebounceCounter[4][4];


void setup() {
  DDRD = 0xFA;//set pins D7-D4 as output, D2 as input
}

// buttonCheck - checks the state of a given button.
//this buttoncheck function is largely copied from the monome 40h firmware by brian crabtree and joe lake
void buttonCheck(byte row, byte index)
{
  if (((buttonCurrent[row] ^ buttonLast[row]) & (1 << index)) &&   // if the current physical button state is different from the
  ((buttonCurrent[row] ^ buttonState[row]) & (1 << index))) {  // last physical button state AND the current debounced state

    if (buttonCurrent[row] & (1 << index)) {                      // if the current physical button state is depressed
      buttonEvent[row] = 1 << index;              // queue up a new button event immediately
      buttonState[row] |= (1 << index);                         // and set the debounced state to down.
  }
    else{
      buttonDebounceCounter[row][index] = 12;
    }  // otherwise the button was previously depressed and now
    // has been released so we set our debounce counter.
  }
  else if (((buttonCurrent[row] ^ buttonLast[row]) & (1 << index)) == 0 &&  // if the current physical button state is the same as
  (buttonCurrent[row] ^ buttonState[row]) & (1 << index)) {        // the last physical button state but the current physical
    // button state is different from the current debounce 
    // state...
    if (buttonDebounceCounter[row][index] > 0 && --buttonDebounceCounter[row][index] == 0) {  // if the the debounce counter has
      // been decremented to 0 (meaning the
      // the button has been up for 
      // kButtonUpDefaultDebounceCount 
      // iterations///

      buttonEvent[row] = 1 << index;    // queue up a button state change event

      if (buttonCurrent[row] & (1 << index)){          // and toggle the buttons debounce state.
        buttonState[row] |= (1 << index);
      }
      else{
        buttonState[row] &= ~(1 << index);
      }
    }
  }
}


void shift(){
  
  for (i=0;i<4;i++){
    
    buttonLast[i] = buttonCurrent[i];
    
    byte dataToSend = (1 << (i+4)) | (15 & ~ledData[i]);
      
    // set latch pin low so the LEDs don't change while sending in bits
    digitalWrite(ledLatchPin, LOW);
    // shift out the bits of dataToSend
    shiftOut(ledDataPin, ledClockPin, LSBFIRST, dataToSend);  
    //set latch pin high so the LEDs will receive new data
    digitalWrite(ledLatchPin, HIGH);
      
    //once one row has been set high, receive data from buttons
    //set latch pin high
    digitalWrite(buttonLatchPin, HIGH);
    //shift in data
    buttonCurrent[i] = shiftIn(buttonDataPin, buttonClockPin, LSBFIRST) >> 3;
    //latchpin low
    digitalWrite(buttonLatchPin, LOW);
    
    for (k=0;k<4;k++){
      buttonCheck(i,k);
    }
  }
}

void updateLEDs(){ //update the leds to reflect hte state of the buttons
  for (j=0;j<4;j++){
    ledData[j] = buttonState[j];
  }
}

void loop() {
  shift();
  updateLEDs();
}

Step 25: Serial Communication

At this point in the project I got a little impatient and wanted to start making some sounds, so I added some things to the firmware to make the Arduino send and receive information serially. I've posted the code below. I used a timer interrupt to keep the Arduino responsive to incoming serial messages, you can read a little more about how that works here. (if you're going to test this code, use the app attached, the newer version of the beat slicer app on github is a little different).

//BUTTON TEST w/ 74HC595 and 74HC165 and serial communication
//by Amanda Ghassaei
//June 2012

/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
*/

//this firmware will send data back and forth with the maxmsp patch "beat slicer"

//pin connections
int ledLatchPin = 6;
int ledClockPin = 5;
int ledDataPin = 7;
int buttonLatchPin = 4;
int buttonClockPin = 3;
int buttonDataPin = 2;

//looping variables
byte i;
byte j;
byte k;
byte ledByte;

//storage for led states, 4 bytes
byte ledData[] = {0, 0, 0, 0};
//storage for buttons, 4 bytes
byte buttonCurrent[] = {0,0,0,0};
byte buttonLast[] = {0,0,0,0};
byte buttonEvent[] = {0,0,0,0};
byte buttonState[] = {0,0,0,0};
//button debounce counter- 16 bytes
byte buttonDebounceCounter[4][4];


void setup() {
  DDRD = 0xFA;//set pins D7-D4 as output, D2 as input
  
  Serial.begin(57600);
  
  cli();//stop interrupts

  //set timer2 interrupt every 128us
  TCCR2A = 0;// set entire TCCR2A register to 0
  TCCR2B = 0;// same for TCCR2B
  TCNT2  = 0;//initialize counter value to 0
  // set compare match register for 7.8khz increments
  OCR2A = 255;// = (16*10^6) / (7812.5*8) - 1 (must be <256)
  // turn on CTC mode
  TCCR2A |= (1 << WGM21);
  // Set CS11 bit for 8 prescaler
  TCCR2B |= (1 << CS11);   
  // enable timer compare interrupt
  TIMSK2 |= (1 << OCIE2A);
  
  sei();//allow interrupts
  
}

// buttonCheck - checks the state of a given button.
//this buttoncheck function is largely copied from the monome 40h firmware by brian crabtree and joe lake
void buttonCheck(byte row, byte index)
{
  if (((buttonCurrent[row] ^ buttonLast[row]) & (1 << index)) &&   // if the current physical button state is different from the
  ((buttonCurrent[row] ^ buttonState[row]) & (1 << index))) {  // last physical button state AND the current debounced state

    if (buttonCurrent[row] & (1 << index)) {                      // if the current physical button state is depressed
      buttonEvent[row] = 1 << index;              // queue up a new button event immediately
      buttonState[row] |= (1 << index);                         // and set the debounced state to down.
  }
    else{
      buttonDebounceCounter[row][index] = 12;
    }  // otherwise the button was previously depressed and now
    // has been released so we set our debounce counter.
  }
  else if (((buttonCurrent[row] ^ buttonLast[row]) & (1 << index)) == 0 &&  // if the current physical button state is the same as
  (buttonCurrent[row] ^ buttonState[row]) & (1 << index)) {        // the last physical button state but the current physical
    // button state is different from the current debounce 
    // state...
    if (buttonDebounceCounter[row][index] > 0 && --buttonDebounceCounter[row][index] == 0) {  // if the the debounce counter has
      // been decremented to 0 (meaning the
      // the button has been up for 
      // kButtonUpDefaultDebounceCount 
      // iterations///

      buttonEvent[row] = 1 << index;    // queue up a button state change event

      if (buttonCurrent[row] & (1 << index)){          // and toggle the buttons debounce state.
        buttonState[row] |= (1 << index);
      }
      else{
        buttonState[row] &= ~(1 << index);
      }
    }
  }
}


void shift(){
  
  for (i=0;i<4;i++){
    
    buttonLast[i] = buttonCurrent[i];
    
    byte dataToSend = (1 << (i+4)) | (15 & ~ledData[i]);
      
    // set latch pin low so the LEDs don't change while sending in bits
    digitalWrite(ledLatchPin, LOW);
    // shift out the bits of dataToSend
    shiftOut(ledDataPin, ledClockPin, LSBFIRST, dataToSend);  
    //set latch pin high so the LEDs will receive new data
    digitalWrite(ledLatchPin, HIGH);
      
    //once one row has been set high, receive data from buttons
    //set latch pin high
    digitalWrite(buttonLatchPin, HIGH);
    //shift in data
    buttonCurrent[i] = shiftIn(buttonDataPin, buttonClockPin, LSBFIRST) >> 3;
    //latchpin low
    digitalWrite(buttonLatchPin, LOW);
    
    for (k=0;k<4;k++){
      buttonCheck(i,k);
      if (buttonEvent[i]<> 1) & 3;
      byte ledx = (ledByte >> 3) & 3;
      if (ledstate){
        ledData[ledy] |= 8 >> ledx;
      }
      else{
        ledData[ledy] &= ~ (8 >> ledx);
      }
    }//end if serial available
  }//end do
 while (Serial.available() > 8);
}    


void loop() {
  shift();//updates leds and receives data from buttons
}

I sent this serial data to an audio processing application I wrote in MaxMSP. You can download this application below (called beat slicer) and open it with MaxMSP or MaxRuntime (free version) here. I'm running Max 5, I assume it will work on Max 6 as well. It will prompt you to select an audio file (wav, mp3, aiff). Then you can manipulate this audio file using the button grid as shown in the video below:

Step 26: Battery

One of my main objectives for this project was to make something portable, so the next step is to add portable power. I used a rechargeable Li-Po battery to minimize waste and provide enough power for hours of use. Additionally, I wanted a Li-Po battery that only had two leads coming out of it so that I could charge it using a regular barrel plug.

Here are the parts for the power setup, taken from the parts list on the first page:

Li-Ion 7.4V Tenergy 2200mAh Rechargeable Battery module with PCB Amazon
Tenergy Universal Smart Charger for Li-Ion/Polymer battery Pack (3.7V-14.8V 1-4 cells) Amazon
Size N Panel-Mount Coaxial DC Power Jack Radioshack 274-1576
Size N Coaxial DC Power Plug Radioshack 274-1573
SPST Toggle Switch Radioshack 275-634

Cut and strip the two leads from the battery (do not let them short out). Make connections between the battery, plug, switch and Arduino according to the schematic above. I like to always attach ground to the outside part of the coaxial jack, but you can wire it however you like (just make sure your wiring of the charger is consistent!).

Cut and strip the two leads from the charger. Solder the n type barrel plug to these leads as shown in the image above. Make sure that the polarity of your charger's barrel plug matches the polarity of the jack. Again, I've chosen to connect ground to the outside part of the coaxial jack/plug in the images above.

Now the switch acts as an on/off switch to the Arduino and the battery can be charged via the barrel plug. Charging Li-Po batteries is a somewhat complicated procedure that involves balancing the cells of the battery, I'm not sure if hooking up the Arduino in parallel with the battery during charging will interfere with this process. Just to be safe, I'm always sure to switch the power switch off during charging, thereby removing the Arduino from the circuit.

Note- be careful when using Li-Po batteries, improper use can result in fire. Be careful not to short circuit the battery and always use the proper charger.

Step 27: Midi Out

This instrument is primarily a MIDI device, so we need to build a MIDI out. There are two ways to do this (and over the course of this project I did one and then switched to the other):

output MIDI via a 5 pin DIN connector (see fig 1)
output MIDI via USB (this is what I eventually settled on)

Either of these options is fine, I chose USB because I didn't want to have to carry a special MIDI to USB cable all the time. If you have a lot of synthesizers that receive a 5 pin MIDI input, it might be more convenient for you to use the 5 pin jack (it's also a little easier). I'll go through both processes below:

5 pin connection:

Solder a 220ohm resistor to pin 4 of the MIDI jack and connect to Arduino 5V. Solder a wire between MIDI pin 2 and ground. Solder a wire between MIDI pin 5 and digital pin 1 (TX).

MIDI over USB:

MIDI over USB is a little tricky. Ideally we'd be able to send MIDI out the USB port already connected to the Arduino, but this turns out to be more trouble than it's worth in my opinion. You can read a little bit about various solutions here. Instead, I found a really great tutorial that explains how you can take apart a cheap MIDI to USB cable, solder new connections to it, and tuck it inside your project enclosure with your Arduino, to create a secondary MIDI-USB output. The process is explained really well on the Shiftmore blog, but the MIDI to USB cable I received from amazon was a little different, so I'll describe the process again here.

Remove the plastic casing from the MIDI to USB cable and unsolder the connections to the cables on either end (fig 8). The USB connections are shown here, make the following connections:

5V to +
DP to D+
DM to D-
VSS to -

As you can see in figs 9 and 10, I used a pieced of perf board to make the connections to the USB jack. On the other side of the MIDI to USB board, make the following connections to the Ardunio:

IN- to Digital Pin 1 (TX)
GND to Arduino Ground

Testing it out:

Load the firmware below onto the Arduino (also in attached file), it will turn the keypad into a simple MIDI device: pressing each of the buttons will cause the button to light up and trigger a MIDI note. Disconnect the Arduino's serial connection and connect the MIDI output to a MIDI instrument or your computer to hear the MIDI notes. You should also see the yellow MIDI IN light on the MIDI to USB board turn on with each note. More info about programming the Arduino to send MIDI can be found here.

//basic midi test
//by Amanda Ghassaei 2012

/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
*/

//this firmware will cause the buttons to light up momentarily while they are pressed.

//pin connections
int ledLatchPin = 6;
int ledClockPin = 5;
int ledDataPin = 7;
int buttonLatchPin = 4;
int buttonClockPin = 3;
int buttonDataPin = 2;

//looping variables
byte i;
byte j;
byte k;

//storage for led states, 4 bytes
byte ledData[] = {0, 0, 0, 0};
//storage for buttons, 4 bytes
byte buttonCurrent[] = {0,0,0,0};
byte buttonLast[] = {0,0,0,0};
byte buttonEvent[] = {0,0,0,0};
byte buttonState[] = {0,0,0,0};
//button debounce counter- 16 bytes
byte buttonDebounceCounter[4][4];

//MIDI variables
int velocity = 100;
int noteON = 144;
int MIDIoffset = 60;

void setup() {
  DDRD = 0xFA;//set pins D7-D4 as output, D2 as input
  
  Serial.begin(31250);//set midi baud rate
}

// buttonCheck - checks the state of a given button.
//this buttoncheck function is largely copied from the monome 40h firmware by brian crabtree and joe lake
void buttonCheck(byte row, byte index)
{
  if (((buttonCurrent[row] ^ buttonLast[row]) & (1 << index)) &&   // if the current physical button state is different from the
  ((buttonCurrent[row] ^ buttonState[row]) & (1 << index))) {  // last physical button state AND the current debounced state

    if (buttonCurrent[row] & (1 << index)) {                      // if the current physical button state is depressed
      buttonEvent[row] = 1 << index;              // queue up a new button event immediately
      buttonState[row] |= (1 << index);                         // and set the debounced state to down.
  }
    else{
      buttonDebounceCounter[row][index] = 12;
    }  // otherwise the button was previously depressed and now
    // has been released so we set our debounce counter.
  }
  else if (((buttonCurrent[row] ^ buttonLast[row]) & (1 << index)) == 0 &&  // if the current physical button state is the same as
  (buttonCurrent[row] ^ buttonState[row]) & (1 << index)) {        // the last physical button state but the current physical
    // button state is different from the current debounce 
    // state...
    if (buttonDebounceCounter[row][index] > 0 && --buttonDebounceCounter[row][index] == 0) {  // if the the debounce counter has
      // been decremented to 0 (meaning the
      // the button has been up for 
      // kButtonUpDefaultDebounceCount 
      // iterations///

      buttonEvent[row] = 1 << index;    // queue up a button state change event

      if (buttonCurrent[row] & (1 << index)){          // and toggle the buttons debounce state.
        buttonState[row] |= (1 << index);
      }
      else{
        buttonState[row] &= ~(1 << index);
      }
    }
  }
}


void shift(){
  
  for (i=0;i<4;i++){
    
    buttonLast[i] = buttonCurrent[i];
    
    byte dataToSend = (1 << (i+4)) | (15 & ~ledData[i]);
      
    // set latch pin low so the LEDs don't change while sending in bits
    digitalWrite(ledLatchPin, LOW);
    // shift out the bits of dataToSend
    shiftOut(ledDataPin, ledClockPin, LSBFIRST, dataToSend);  
    //set latch pin high so the LEDs will receive new data
    digitalWrite(ledLatchPin, HIGH);
      
    //once one row has been set high, receive data from buttons
    //set latch pin high
    digitalWrite(buttonLatchPin, HIGH);
    //shift in data
    buttonCurrent[i] = shiftIn(buttonDataPin, buttonClockPin, LSBFIRST) >> 3;
    //latchpin low
    digitalWrite(buttonLatchPin, LOW);
    
    for (k=0;k<4;k++){
      buttonCheck(i,k);
    }
  }
}

void updateLEDs(){ //update the leds to reflect hte state of the buttons
  for (j=0;j<4;j++){
    ledData[j] = buttonState[j];
  }
}

void MIDImessage(int command, int MIDInote, int MIDIvelocity) {//send s a MIDI message
  Serial.write(command);//send note on or note off command 
  Serial.write(MIDInote);//send pitch data
  Serial.write(MIDIvelocity);//send velocity data
}

void sendMIDI(){
  for (byte a=0;a<4;a++){
    for (byte b=0;b<4;b++){
      if (buttonEvent[a]&(1<<b)){
        buttonEvent[a]&=~(1<<b);//zero button event
        if (buttonState[a]&(1<<b)){
          MIDImessage(noteON,(MIDIoffset+a*5+b),100);
        }
        else{
          MIDImessage(noteON,(MIDIoffset+a*5+b),0);
        }
      }
    }
  }
}


void loop() {
  shift();
  updateLEDs();
  sendMIDI();
}

Step 28: Accerometer/Gyro

I attached a 2 axis gyroscope and 3 axis accelerometer onto this project so that I could add some interesting control to the device. The 5 degrees of freedom board from Sparkfun outputs data from its gyroscope and accelerometer as analog voltages. I sent these to analog pin 0-4. You may notice that the Gyro has four outputs- I chose to use the X/Y4.5 out instead of the X/YRate out because the 4.5 has higher resolution. I wrote more about this board and explained some of the code I used to get it up and running here.

Solder header pins on the gyro/accelerometer board. Solder on the perfboard, making sure to leave room for the Arduino to fit on top. Make the following pin connections:

RAW - Arduino 5V
GND- Arduino ground
X4.5- A2
Y4.5- A0
XAcc- A4
YAcc- A3
ZAcc- A1 (I ended up disconnecting this later to free up an analog input for a second potentiometer)

Upload the following code and check the serial monitor to make sure accelerometer/gyro is functioning properly. When the board is lying still and parallel to the ground the values of xGyro, yGyro, xAcc, and yAcc should all hover around 0. zAcc should output a value around -66 (see fig 8). Move the board around and see how the values change. In figure 9 you can see how rotation about the x axis changes xGyro and y and zAcc, but not yGyro or xAcc.
//Analog Accerometer w Serial
//by Amanda Ghassaei
//instructables.com/amandaghassaei
//August 2012

/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
*/ 
 
 //setup acceleration variables
 int xAcc;
 int yAcc;
 int zAcc;

 //setup gyre variables
 int xGyro;
 int yGyro;
 
 int zero = 282;//this was the zero point value for my accelerometer, your board may be slightly different.

void setup(){
  Serial.begin(9600);//set up serial
}

void loop(){
  
  //read values
  xGyro = analogRead(A2);
  yGyro = analogRead(A0);
  xAcc = analogRead(A4);
  yAcc = analogRead(A3);
  zAcc = analogRead(A1);

  
  //print values
  Serial.print("xGyro ");
  Serial.println(317-xGyro);
  Serial.print("yGyro ");
  Serial.println(183-yGyro);
  Serial.print("xAcc ");
  Serial.println(zero-xAcc);
  Serial.print("yAcc ");
  Serial.println(zero-yAcc);
  Serial.print("zAcc ");
  Serial.println(zero-zAcc);
  Serial.println(" ");
  delay(500);//wait

}

Once you add the potentiometers, you will be able to use the accelerometer/gyro for gestural control, as shown in the following video:

Step 29: Pots

Connect a black wire to the left lead of a 10K linear taper potentiometer. Connect a green wire to the middle lead. Connect a red wire to the remaining lead. Repeat this for the other potentiometer. Connect the other end of the red wires to 5V, the black wires to ground, and the green wires to Analog in

Use pliers to remove the pin on the side of the pots, so that you can mount it more easily in your project enclosure.

Step 30: Enclosure

I borrowed an idea from former Artist in Residence Mads Hobye for my enclosure. Mads founds these sleek boxes at the container store and used them to make project enclosures for the various musical instruments he built during his stay. These boxes are particularly convenient because they have a bevel around the top that allows you to easily mount a 5mm acrylic front panel.

I mounted all the components in the box either using epoxy (Amazon), or for less permanent bonding, I used a foam core adhesive tape (Amazon).

I used a laser cutter to cut out two USB ports (one for the Arduino and one for MIDI out) in the bottom of the enclosure. Then I used a drill to make holes for two pots, a power switch, and a charging jack. The vector files are attached (scTopLaser, scBottomLaser).

I laser cut 2.5cm standoffs from 3mm ply and epoxied them into the enclosure. I laser cut a backing plate (SCsupport.pdf) for the button pcb from 0.25" ply and screwed it down to the standoffs with small wood screws.

Originally, I laser cut a front panel from translucent white 5mm acrylic so that it would snap fit into the wood box. Later, I waterjet an aluminum from panel from 3mm aluminum sheet. I secured the aluminum front panel to the pcb backing plate with small, countersunk machine screws. I drilled out four holes in the laser cut pcb backer and epoxied some small nuts for the screws to clamp to. The vector file is attached (SCface.pdf).

Step 31: Final Firmware

For the final firmware, I've extracted all the code that controls the buttons and leds into a library to make it more tidy, all of this is in a class called SugarCube. I was inspired by the work I've been doing on the Instructables iOS app, and wrote the event handling pieces of the code so that they work in a similar way that an iPhone deals with touch and other gestural events. Basically I created a set of methods that each app can subscribe to, things like "deviceWasShaken" or "buttonPressed". When the SugarCube class detects one of these events, it tells the current app to execute the corresponding method. If you're interested in seeing an example of this structure in action, check out SimpleMIDIKeyboard.cpp, it shows how few lines of code are needed to wire up all the button and analog controls to MIDI outputs. I hope to eventually write out a little more complete documentation for how to write your own apps based on this framework, please let me know if there is interest. This is by far my biggest piece of C++ code, and I am by no means an expert in C++, I'd love to hear an expert's thoughts on how I did!

Step for running the code:

Download the zip file from github

unzip

rename the folder to "SugarCubeLibraryFiles"

open the file SugarCubeLibraryFiles.ino in Arduino

connect your Arduino and upload

The controller boots up into several different apps. In the main file, you'll see a section with case 0, case 1, case 2.... etc. The buttons on the controller are named 0-15 starting from the top left corner, going left to right. If you press button 0 (top left) after turning the controller on, you will boot into Step Sequencer mode, holding down button 1 (the one to the right of button 0) will boot into Flin, and so on.

Step 32: Future Work

This project has the potential to be expanded upon quite a bit. Unfortunately, I just don't have the time to invest in exploring all the possibilities, but here's some ideas I had for things to look into:

More apps: The current implementation of this device allows you to boot into 16 different applications, but I've only written seven so far. There's a ton of great ideas over on the monome website for grid based controllers, it'd be great to see some of that translated into Arduino.

Gyro Control: As I mentioned earlier, I threw an x/y gyroscope in the controller, but I've yet to write an app that actually uses it. I'd love to hear if someone has an idea for how this could work with MIDI.

Wireless: When I started this project, my major design objectives were portability and plug and play ease of use. I wanted to try to break away from the model of the electronic controller that necessitates a computer to run, in an effort to bring electronic music out of the traditional studio environment. In keeping with that idea, I'd like to eventually get this controller to wirelessly send MIDI to my phone to make it totally portable. I have one of these bluetooth boards from Red Bear Labs, and I think there might be some way to send the data to my phone, translate it into CoreMIDI and run it though a MIDI synth, but I just haven't explored the idea enough yet. If anyone has any insight, I'd love to hear your thoughts.

Step 33: Appendix: Cut PCB for Control Buttons

Originally, I planned to have four extra "control" buttons on the side of the controller that I was going to use in various applications. I started wiring it up, but eventually scrapped it. I haven't written any code for these buttons, and they are in no way integrated into the apps I've written, but I figured I'd still include the images that I took during that process in this Instructable in case it's useful to anyone.

Cut the 2x2 sparkfun pcb as shown in the pictures above. Solder white LEDs and diodes on the pcb as in steps 2 and 3.

Step 34: Appendix: Control Buttons Wiring Part 1: PCB

Cut a piece of ribbon cable and solder 8 wires to the sparkfun PCB holes labelled "switch gnd" and "led gnd". Solder four more wires to the holes labelled "switch" and "blue." See the images for more info.

On one half of the PCB (the one labelled "green" and "blue") you will have to rewire some of the traces that were broken when the PCB was cut. Both connections to the positive switch rail will need to be connected to each other and then connected to the "green" led trace as shown in fig 4. I did this by removing one strand of a piece of stranded wire and poking it through the vias on the PCB. Use a dab of solder to secure the electrical connection between the copper strand and the PCB (fig 7). You will also have to solder a wire between the two "blue" positive rails (also shown in fig 4). Once this is done, test for continuity and cover the exposed copper with electrical tape to prevent short circuits (fig 6).

On the other half of the PCB, use a jumper wire to connect the "red" and "blue" sockets of one of the LEDs together (see fig 7). This will connect the anode of your white LEDs to the ribbon cable.

Step 35: Appendix: Control Buttons Wiring Part 2: Socket

Clamp a 16 pin socket onto the ribbon cable as shown in fig 1. Solder two rows of male header pins to the protoboard so that the control buttons fit onto the board as shown in fig 3. Trim any excess ribbon cable.

Step 36: Appendix: Control Buttons Wiring Part 3: Header Pins

Solder 3 more male header pins to snap to digital pins 11-13. Since the spacing between Arduino digital pins 0-7 and pin 8-13, I had to drill holes in my perfboard and scrape off some of the copper traces. See the images above for more information.

Step 37: Appendix: Control Buttons Wiring Part 4: Connections to LEDs

Solder four 68ohm resistors to the pins which connect to the LED cathodes. Connect the other end of these resistors to pins 4-7 of the 74HC595 with jumper wires (yellow).

We'll be using pin 11 of the Arduino to supply positive voltage to the LEDs, but one Arduino pin cannot source enough current to drive the LEDs by itself. I used a 222 NPN transistor in an emitter-follower configuration to boost the power of pin 11's signal. Connect pin 11 to the base (middle pin) of the transistor. Connect the collector to the Arduino's 5V supply and the emitter to the header pins which connect to the LED anodes (fig 5).

Step 38: Appendix: Control Buttons Wiring Part 5: Connections to Buttons

Solder a jumper wire between pin 13 of the Arduino and the header pins which attach to the button anodes.

On the reverse side of the perfboard I soldered four jumper wires from the button cathode pins to 10k resistors connected to ground (fig 4). I did this to save space on my PCB so that it would fit in an enclosure better. I also soldered four jumper wires from the non grounded side of the 10k resistors to 165 pins 3-6.

Comments

author
BGprojectz made it! (author)2017-03-25

Thx for this amazing instructable!

Still busy trying things out and modifying it...

My progress so far:

author
amandaghassaei made it! (author)amandaghassaei2017-03-27

nice, glad to see this worked! what are you going to do with it next?

author
BGprojectz made it! (author)BGprojectz2017-03-28

Thx! First making a enclosure.

I did use RGB LEDs. Would be nice if i can modify the circuit and program to let it change colors.

And if above works, maybe showing little animations on it.

author
amandaghassaei made it! (author)amandaghassaei2017-04-01

oh wow that's cool! Do you have them set up for pwm-ing? would love to see more videos as you progress with this!

author
ChadP45 made it! (author)2017-03-23

Great guide, built in and got in working. I've been using it in both Traktor and Ableton Live. I do have a question though - how can I get it to light LEDs other than than the one associated with the button press?

Something along the lines of this: https://youtu.be/Jkvq_6Jg6UU?t=387

author
amandaghassaei made it! (author)amandaghassaei2017-03-27

you mean you want to be able to control the leds to make them do other things? They won't be able to change color or brightness bc the circuit isn't set up for that, but you could write your own app to control them in different ways.

this is the basic keyboard app:

https://github.com/amandaghassaei/Sugarcube-Arduin...

see how you can add code to different events? I would start from there if you want to program something yourself.

author
ChadP45 made it! (author)ChadP452017-03-28

Sorry if I wasn't clear. I don't want them to change colour, I just want to be able to make them light by a MIDI signal coming from the DAW, and not just because a button was pressed.

author
amandaghassaei made it! (author)amandaghassaei2017-04-01

yeah I think it's possible. I haven't implemented any midi receive stuff yet, but you can do it with arduino's serial library:

https://www.arduino.cc/en/reference/serial

https://www.instructables.com/id/Send-and-Receive-...

author
pauliesyllabic made it! (author)2016-09-13

This is project looks wonderful. Does anyone have an idea how much work would need to be done to output to a simple speaker instead of a MIDI device? I'm guessing I would have to nix the MIDI altogether and rig up something with tones? I'm willing to put in the work, but this will be my first project and I'm not familiar with the limitations of arduino. Thank you

author
amandaghassaei made it! (author)amandaghassaei2017-03-27

arduino isn't really set up to store large amounts of audio data and output analog, but you can get external modules that you can connect to arduino to make that work (though the code gets a little tricky). My only concern is that this project already uses a lot of io pins and you might find that you run out of other resources on the board - timer/counters etc.

author
Wezmabini made it! (author)2017-03-21

It has been a while since this went up. It still looks great.

What I want to is change programs, on a midi device, in particular to call up presets from an audio signal processor.

Can you suggest an app that will make the Sugar Cube output program change data?

Thanks a lot for posting the Sugar Cube project.

author
amandaghassaei made it! (author)amandaghassaei2017-03-27

you could definitely write an app that caused the sugarcube to send a program change message:

https://en.wikipedia.org/wiki/General_MIDI#Program...

the sugarcube class in this code has a method to send a generic midi command:

void sendMIDI(byte command, byte param1, byte param2);

this could be used to send the change program message.

author
T0BY made it! (author)2016-12-03

This is beautiful, I want one!

author
saurava3 made it! (author)2016-05-24

hey...i want to know that which COM port of arduino should be connected to the beat slicer.

We are having a problem in producing beats using beat slicer with arduino.

author
amandaghassaei made it! (author)amandaghassaei2016-05-24

in Max if you send a "bang" to the serial object and then look at what's printed it will tell you which port - a, b, c, d, e, etc You can set the port by clicking on the one of the buttons attached to the serial object.

author
julianreed051 made it! (author)julianreed0512016-06-11

how do I do all that? I haven't used Max before.

author
amandaghassaei made it! (author)amandaghassaei2016-06-19

you'll have to look through the reference pages:

https://docs.cycling74.com/max5/refpages/max-ref/serial.html

author
saurava3 made it! (author)saurava32016-05-24

So, Let me try and then let you know whether its working or not.

And one more, during steps 18-24 , after executing them my LED's are automatically on where has it should be operated by us by pressing the buttons.

So if you have any solutions regarding this problem, do let me know asap as I have to show this project working tomorrow in my university.

author
amandaghassaei made it! (author)amandaghassaei2016-05-26

leds could be wired backwards? do they turn off when you would expect them to be on?

author
gladamirflint made it! (author)2016-05-19

I'm stuck at Testing LED's...

I checked all my wiring, all is as you wrote in the text for all steps so far. I checked continuity for any shorts, or bad bridges- all are good. The ribbon cable had good connection with both boards, i think the issue for me are the IC's that go into the sockets. I was not particularly conscious about ESD, they might be fried from some discharge.

If you don't mind, have a quick look at the pictures of my wiring and solder bridges. It may be hard to see some wires, but if you see anything fishy I can get better pictures of the area. I believe it's something I misinterpreted, or the fried IC's. If yo don't see any issues with my wiring, I'll go ahead and order new IC's for another (safer) attempt.

author
gladamirflint made it! (author)gladamirflint2016-05-20

edit- here's the pictures. Didn't upload from mobile for some reason.

image2.JPGimage1.JPG
author
amandaghassaei made it! (author)amandaghassaei2016-05-22

the connections look fine. what are the symptoms? no leds are turning on? In my experience, the ics used to drive the leds are pretty robust, I haven't seen one get fried in normal circumstances - I'm not generally too careful about esd. Do you have an oscillascope to debug the output from the ics?

author
gladamirflint made it! (author)gladamirflint2016-05-22

I don't have an oscilloscope- I can find someone who does though. The LED's are not lighting up at all.

What should I look for on the oscilloscope if I get to testing it?

author
amandaghassaei made it! (author)amandaghassaei2016-05-24

ok, use a multimeter to check the voltage across the leds to see if they're even getting power. Are you sure the leds are installed in the correct orientation?

author
gladamirflint made it! (author)gladamirflint2016-05-25

Your idea for checking voltage across the LED's was brilliant- they were barely getting anything- around 0.2v. It turns out, i had forgotten to attach the 5V/GND from the arduino to the IC's.

Needless to say, i'm very thankful for your help, it works great now. (I would recommend editing the step right before testing the LED's, when you say:

Pin connections:

74HC595 Arduino

data pin (pin 14) digital pin 7
latch pin (pin 12) digital pin 6
clock pin (pin 11) digital pin 5

I read past the full two sentences where it says to connect 5V/GND. I was confused by the "Pin connections" part, and thought those were the only added connections. Simply adding "5V to 5V Arduino; GND to GND Arduino" might help out in the future for others.

Working on getting the rest of it done, great instructable so far!

author
amandaghassaei made it! (author)amandaghassaei2016-05-26

yeah at some point I think there was formatting to make that list more clear. I fixed it. glad to hear you solved it!

author
dorseynr made it! (author)2015-09-10

Is anyone else having trouble loading the code from Step 28? I get an error when verifying the tilting test for the two bottom pieces of code for lighting up pixels as you tilt the sensor.

author
amandaghassaei made it! (author)amandaghassaei2015-09-11

what's the error?

author
dorseynr made it! (author)dorseynr2015-09-12

Thanks for the speedy reply! You are my hero. Here's the error for the middle piece of code when I try to copy and paste it from Step 28:

Arduino: 1.5.6-r2 (Windows 8), Board: "Arduino Uno"

sketch_sep12a.ino: In function 'void checkFirstButton()':
sketch_sep12a:170: error: expected `)' before '{' token
sketch_sep12a:207: error: expected primary-expression before '}' token
sketch_sep12a:207: error: expected `;' before '}' token
sketch_sep12a:209: error: a function-definition is not allowed here before '{' token
sketch_sep12a:379: error: expected `}' at end of input
sketch_sep12a:379: error: expected `}' at end of input
sketch_sep12a:379: error: expected `}' at end of input

And here's the error for the third piece of code:

Arduino: 1.5.6-r2 (Windows 8), Board: "Arduino Uno"

sketch_sep12a.ino: In function 'void shift()':
sketch_sep12a:191: error: expected primary-expression at end of input
sketch_sep12a:191: error: expected `;' at end of input
sketch_sep12a:191: error: expected `}' at end of input
sketch_sep12a:191: error: expected `}' at end of input
sketch_sep12a:191: error: expected `}' at end of input
sketch_sep12a:191: error: expected `}' at end of input

author
amandaghassaei made it! (author)amandaghassaei2015-09-13

yeah I can see there's a bit of code missing there. I'll try to see if I can find the hard-drive that should be stored on. Those little bits of code along the way were all scrapped when I wrote the final code for the controller. So if you plan on using my final firmware (on github) everything should be fine. Does that work?

author
saurava3 made it! (author)saurava32016-05-24

hey...i want to know that which COM port of arduino should be connected to the beat slicer.

We are having a problem in producing beats using beat slicer with arduino.

author
Rachel RoseU made it! (author)2015-11-06

Hi Amanda!

Just wanted to thank you for this instructable, I learned so much while making it! It was my first time making something like this and it was quite daunting but I'm happy to say that everything works. :)

I just had a quick question about how you mounted all of the parts inside the box. I looked at Mads instructables to see how he did it for his devices but just wanted to ask, did you just put small pieces of wood and put in screws through the corners of the button pad+pcb?

Thanks again! This was a lot of fun to make. :)

-------

Also, just putting this out there in case it is useful, I haven't used a laser cutter before, so I ended up laser cutting the acrylic with the eps file Amanda provided through Ponoko. Since it was fairly simple to laser cut it ended up being free (at time of writing they let you laser cut your first project for free) :D

author
amandaghassaei made it! (author)amandaghassaei2015-11-07

Hi! Glad to hear it works. I never really properly mounted everything in the project box, I've been meaning to do that, right now the front panel is just press fits into the top of the box. One way that might be cool is to mount the electronics on the inside of the box with some support behind the button pad pcb so you have something to press against when you hit the buttons. Then epoxy some magnets on the inside corners of the box and the underside of the front panel so it snaps into place, but you can still open it up easily if you need.

Would love to see a pic of the final product! How did you end up mounting the usb output in the box?

author
MGuezz made it! (author)2015-08-10

Wow, I'm definitely working on an implementation of this controller for a guitar. I already have a wireless MIDI module that I can power off the battery on this design.

The question is... do you think I could have its onboard sequencer sync to Midi Clock? Say I have an Arduino down the line where I can pick up Midi Clock, could the Arduino send via RF Midi Clock to the SugarCube to get it to sync?

Is there a simpler idea?

author
MatthewT7 made it! (author)2015-07-02

Does anyone happen to have a PCB design of this already? Fritzing/Eagle/DipTrace? If not, im in the process of making one as i wouldnt mind making some additional changes and making these over and over with perfboard gets really time consuming =-)

author
amandaghassaei made it! (author)amandaghassaei2015-07-18

nice! let me know how that goes, it might make sense for me to eventually move documentation over to a wiki if there's interest in doing mods and stuff. Have you successfully finished a perfboard version yet?

author
MatthewT7 made it! (author)MatthewT72015-07-18

Yep! It took me a few tries because I'm apparently terrible at those solder bridges but I eventually got it. I'm in the process of printing a prototype shield so once I verify it's good I'll post up the schematic and pcb design :-)

author
kennethharris made it! (author)2015-05-11

I really like it.. Well done

author
stevenelson55 made it! (author)2015-05-07

Really mind blowing

author
adamrussell made it! (author)2015-05-04

This is amazing

author
denniscook made it! (author)2015-05-02

Fantastic, it works beautifully

author
kierondeane made it! (author)2015-04-22

Hi Amanda is there a way to adapt the button test code to print the button presses straight to the serial monitor. im trying to encorporate part of the code into a bigger patch.

author
markkuarimo made it! (author)2015-04-05

My version of a Arduino SugarCube based on this instructable. Mine has 4 pots, no gyroscope, no accelerometer, no battery power, just a MIDI controller for my project studio. I edited all the code to suit my own basic needs, uploaded the firmware and everything it works great! Thanks Amanda! :)

WP_20150402_21_32_31_Pro.jpg
author
kierondeane made it! (author)2015-02-23

hi i have completed this build but am getting this error when uploading the final code.


This report would have more information with

"Show verbose output during compilation"

enabled in File > Preferences.

Arduino: 1.0.6 (Mac OS X), Board: "Arduino Uno"

sugarcube/SugarCube.cpp.o: In function `SugarCube':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:13: multiple definition of `SugarCube::SugarCube()'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:13: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:13: multiple definition of `SugarCube::SugarCube()'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:13: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::timer1Setup()':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:77: multiple definition of `SugarCube::timer1Setup()'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:77: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::timer2Setup()':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:99: multiple definition of `SugarCube::timer2Setup()'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:99: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::setDefaultPinConnections()':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:121: multiple definition of `SugarCube::setDefaultPinConnections()'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:121: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::setLedLatchPin(unsigned char)':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:137: multiple definition of `SugarCube::setLedLatchPin(unsigned char)'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:137: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::setLedClockPin(unsigned char)':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:144: multiple definition of `SugarCube::setLedClockPin(unsigned char)'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:144: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::setLedDataPin(unsigned char)':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:149: multiple definition of `SugarCube::setLedDataPin(unsigned char)'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:149: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::setButtonLatchPin(unsigned char)':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:154: multiple definition of `SugarCube::setButtonLatchPin(unsigned char)'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:154: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::setButtonClockPin(unsigned char)':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:159: multiple definition of `SugarCube::setButtonClockPin(unsigned char)'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:159: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::setButtonDataPin(unsigned char)':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:164: multiple definition of `SugarCube::setButtonDataPin(unsigned char)'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:164: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::setXAccPin(unsigned char)':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:169: multiple definition of `SugarCube::setXAccPin(unsigned char)'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:169: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::setYAccPin(unsigned char)':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:174: multiple definition of `SugarCube::setYAccPin(unsigned char)'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:174: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::setPot1Pin(unsigned char)':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:179: multiple definition of `SugarCube::setPot1Pin(unsigned char)'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:179: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::setPot2Pin(unsigned char)':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:184: multiple definition of `SugarCube::setPot2Pin(unsigned char)'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:184: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::setXGyroPin(unsigned char)':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:189: multiple definition of `SugarCube::setXGyroPin(unsigned char)'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:189: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::setYGyroPin(unsigned char)':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:194: multiple definition of `SugarCube::setYGyroPin(unsigned char)'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:194: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::getStateOfButton(unsigned char, unsigned char)':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:239: multiple definition of `SugarCube::getStateOfButton(unsigned char, unsigned char)'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:239: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::getStateOfButtonRow(unsigned char)':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:247: multiple definition of `SugarCube::getStateOfButtonRow(unsigned char)'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:247: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::getXAxisGyroVal()':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:321: multiple definition of `SugarCube::getXAxisGyroVal()'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:321: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::getYAxisGyroVal()':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:326: multiple definition of `SugarCube::getYAxisGyroVal()'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:326: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::getPot1Val()':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:331: multiple definition of `SugarCube::getPot1Val()'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:331: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::getPot2Val()':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:336: multiple definition of `SugarCube::getPot2Val()'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:336: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::turnOnLED(unsigned char, unsigned char)':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:347: multiple definition of `SugarCube::turnOnLED(unsigned char, unsigned char)'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:347: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::turnOffLED(unsigned char, unsigned char)':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:352: multiple definition of `SugarCube::turnOffLED(unsigned char, unsigned char)'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:352: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::setLEDState(unsigned char, unsigned char, unsigned char)':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:355: multiple definition of `SugarCube::setLEDState(unsigned char, unsigned char, unsigned char)'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:355: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::setLEDsByArray(unsigned char*)':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:364: multiple definition of `SugarCube::setLEDsByArray(unsigned char*)'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:364: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::setLEDRow(unsigned char, unsigned char)':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:397: multiple definition of `SugarCube::setLEDRow(unsigned char, unsigned char)'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:397: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::turnOnLED(unsigned char, unsigned char)':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:402: multiple definition of `SugarCube::setLEDCol(unsigned char, unsigned char)'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:402: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::clearLEDs()':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:410: multiple definition of `SugarCube::clearLEDs()'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:410: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::buttonCheck(unsigned char, unsigned char)':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:494: multiple definition of `SugarCube::buttonCheck(unsigned char, unsigned char)'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:494: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::setXGyro(int)':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:583: multiple definition of `SugarCube::setXGyro(int)'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:583: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::setYGyro(int)':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:591: multiple definition of `SugarCube::setYGyro(int)'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:591: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::setPot1(int)':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:599: multiple definition of `SugarCube::setPot1(int)'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:599: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::setPot2(int)':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:607: multiple definition of `SugarCube::setPot2(int)'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:607: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::checkForShake()':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:615: multiple definition of `SugarCube::checkForShake()'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:615: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::setDelegate(Delegate*)':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:727: multiple definition of `SugarCube::setDelegate(Delegate*)'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:727: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::timer2Routine()':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:704: multiple definition of `SugarCube::timer2Routine()'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:704: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::setupSerialCommunication()':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:679: multiple definition of `SugarCube::setupSerialCommunication()'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:679: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::setupMIDICommunication()':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:645: multiple definition of `SugarCube::setupMIDICommunication()'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:645: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::sendMIDI(unsigned char, unsigned char, unsigned char)':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:666: multiple definition of `SugarCube::sendMIDI(unsigned char, unsigned char, unsigned char)'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:666: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::pitchBend(unsigned char, unsigned char)':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:661: multiple definition of `SugarCube::pitchBend(unsigned char, unsigned char)'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:661: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::noteOff(unsigned char, unsigned char)':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:656: multiple definition of `SugarCube::noteOff(unsigned char, unsigned char)'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:656: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::noteOn(unsigned char, unsigned char, unsigned char)':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:651: multiple definition of `SugarCube::noteOn(unsigned char, unsigned char, unsigned char)'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:651: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::scaleAcc(int)':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:577: multiple definition of `SugarCube::scaleAcc(int)'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:577: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::setYAcc(int)':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:566: multiple definition of `SugarCube::setYAcc(int)'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:566: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::setXAcc(int)':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:555: multiple definition of `SugarCube::setXAcc(int)'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:555: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::getYAxisAccVal()':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:316: multiple definition of `SugarCube::getYAxisAccVal()'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:316: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::getXAxisAccVal()':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:311: multiple definition of `SugarCube::getXAxisAccVal()'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:311: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::analogValFromPin(unsigned char, int)':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:546: multiple definition of `SugarCube::analogValFromPin(unsigned char, int)'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:546: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::checkAnalogPins()':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:535: multiple definition of `SugarCube::checkAnalogPins()'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:535: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::initAnalogPins()':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:525: multiple definition of `SugarCube::initAnalogPins()'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:525: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::setLEDsByBitmap(unsigned char*, unsigned char)':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:377: multiple definition of `SugarCube::setLEDsByBitmap(unsigned char*, unsigned char)'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:377: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::numPressedButtons(unsigned char*)':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:283: multiple definition of `SugarCube::numPressedButtons(unsigned char*)'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:283: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::getPressedButtons(unsigned char (*) [2])':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:265: multiple definition of `SugarCube::getPressedButtons(unsigned char (*) [2])'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:265: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::getStateOfButtonCol(unsigned char)':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:252: multiple definition of `SugarCube::getStateOfButtonCol(unsigned char)'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:252: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::shift(unsigned char)':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:421: multiple definition of `SugarCube::shift(unsigned char)'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:421: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::timer1Routine()':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:690: multiple definition of `SugarCube::timer1Routine()'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:690: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::getButtonStatesBitmap(unsigned char, unsigned char*)':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:217: multiple definition of `SugarCube::getButtonStatesBitmap(unsigned char, unsigned char*)'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:217: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::getButtonStatesArray(unsigned char (*) [4])':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:201: multiple definition of `SugarCube::getButtonStatesArray(unsigned char (*) [4])'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:201: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::setupInputsAndOutputs()':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:55: multiple definition of `SugarCube::setupInputsAndOutputs()'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:55: first defined here

sugarcube/SugarCube.cpp.o: In function `SugarCube::init()':

/Users/kierondeane/Documents/Arduino/libraries/sugarcube/SugarCube.cpp:39: multiple definition of `SugarCube::init()'

sketch_feb23a.cpp.o:/Applications/sketch_feb23a.ino:39: first defined here

core.a(main.cpp.o): In function `main':

/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/main.cpp:40: undefined reference to `setup'

/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/main.cpp:43: undefined reference to `loop'


any help would be greatly appreciated

author
amandaghassaei made it! (author)amandaghassaei2015-03-22

maybe try a fresh download? what version of arduino are you using?

author
kierondeane made it! (author)kierondeane2015-03-23

im using the newest version of the arduino ide and arduino uno. all test codes such as buttons and led test code works the rest get this same error

author
amandaghassaei made it! (author)amandaghassaei2015-03-23

I think maybe you put the folder in Arduino/libraries? you don't actually have to do that, you can just download the zip from github, unzip, change the folder name to "SugarCubeLibraryFiles" and then open the SugarCubeLibraryFiles.ino file inside.

I tested it on the latest version of arduino, should work. Jut make sure you have the right board selected.

Sorry if that was confusing!

author
markkuarimo made it! (author)2014-12-07

Hello again! :) Had to take a long break from this due to other school work keeping me busy. Ok, I re-read steps 19-24 with your updated notes taken into account. The "Test Buttons" arduino code when run on my build results in the following inverted behavior: all the LEDs are lit up after uploading the code and while pressing a button each LED momentarily turns off (i.e. when pressed) and is lit back up after release of button. I don't know why this is and I have allegedly checked all my other connections to the best of my ability that is.... :( P.S. Note, Step 18: Test LEDs code is working as it should = OK. I went all the way back to re-trace the steps 1 thru 24 documentation to see what I might have done wrong.

WP_20141208_03_33_26_Pro.jpg
author
amandaghassaei made it! (author)amandaghassaei2014-12-24

did you work this out? sounds like the leds are fine but something is up with the button wiring. Are the diodes in the right direction?

author
markkuarimo made it! (author)markkuarimo2015-01-04

Does are in the right direction, yes. Still having this issue, and yes something is wrong with the button wiring. any suggestions?

About This Instructable

102,449views

688favorites

License:

Bio: I'm a grad student at the Center for Bits and Atoms at MIT Media Lab. Before that I worked at Instructables, writing code for ... More »
More by amandaghassaei:OTCA Metapixel - Conway's Game of Life"9 Degrees of Freedom" IMUTwitter Controlled Pet Feeder
Add instructable to: