Skip to content

Instantly share code, notes, and snippets.

@aaronparsekian
Created October 21, 2015 15:59
Show Gist options
  • Save aaronparsekian/2bde05a7402b3847e69e to your computer and use it in GitHub Desktop.
Save aaronparsekian/2bde05a7402b3847e69e to your computer and use it in GitHub Desktop.
var serial; // Declare a "SerialPort" object
var proxPin = 0; // Variable from the Proximity Sensor
function preload() {
music = loadSound('youFlyMe.mp4'); //load sound from project folder
}
function setup() {
createCanvas(600, 400);
serial = new p5.SerialPort();
serial.open("/dev/cu.AdafruitEZ-Link744f-SPP");
serial.onData(gotData);
music.play(); //play youFlyMe.mp4
}
function gotData() {
var data = serial.readLine(); // Read the data as text (a string)!
if (data.length > 0); { // Check to make sure something really came in
proxPin = Number(data)
print(proxPin);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment