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