Skip to content

Instantly share code, notes, and snippets.

Created September 28, 2017 01:18
  • 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
What would you like to do?
This for the Final Prototype for the Atelier class. Basically it's trigger with a split ground wire and when the circuit is complete it allows the track in the code to play.
Mad Samurai Beat Machine
Group members: Tristan Santos, Harit Lad, William Selviz
This is the Processing code that talks to Arduino via Arduino Firmata.
The code uses two libraries, Minim and Arduino Frimata, and allows us to use the Arduino
as an input and the laptop (Processing) as a output.
Used the example of PlayAFile from Minim Library;
Uses parts of the Arduino Firmata Playground:
This code can be found from the examples under;
> Arduino (Firmata)
> arduino_input
The one I used was the one from the website itself
//Calling the Libraries
import ddf.minim.*;
import processing.serial.*;
import cc.arduino.*;
Arduino arduino; // Call Arduino
Minim minim; // Call Minim Library
AudioPlayer Samurai; // Call Audioplayer
int mad = 7; // digital pin 7 (the one we are using
color off = color(4, 79, 111);
color on = color(84, 145, 158);
// These are just fill of color to make sure things are working
void setup() {
size(470, 280);
arduino = new Arduino(this, "/dev/cu.usbmodem1411", 57600); // Calling in the arduino and delcaring pin and speed of reading
minim = new Minim(this); // Calling in Minim Library
Samurai = minim.loadFile("Frank Ocean - Chanel.mp3"); // Telling Minim to use the file in the brackets
//for (int i = 0; i <= 13; i++)
arduino.pinMode(mad, Arduino.INPUT); // Telling the Arduino that we want to use pinMode and declaring the pin as well as INPUT
void draw() {
//for (int i = 0; i <= 13; i++) {
if (arduino.digitalRead(mad) == Arduino.HIGH) { // If the digital pin is reading High (activate);
fill(on); // Then fill in the the colour
Samurai.loop(); //Loop the track
println("off"); // And print off
}else{ // If read low
fill(off); // Then draw outline; // Play the track
println("on"); // print on
rect(420 - mad * 30, 30, 20, 20); // This is the visual
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment