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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Mad Samurai Beat Machine | |
Group members: Tristan Santos, Harit Lad, William Selviz | |
DIGF-2004-001 | |
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. | |
Reference: | |
Used the example of PlayAFile from Minim Library; | |
http://code.compartmental.net/minim/ | |
>Examples | |
>Minim | |
>Basic | |
>PlayAFile | |
Uses parts of the Arduino Firmata Playground: | |
https://playground.arduino.cc/Interfacing/ProcesssHackForFirmata | |
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() { | |
background(off); | |
stroke(on); | |
//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 | |
Samurai.play(); // 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