I'm using Arduino with Processing. So I wan't to do stuff with the Arduino on the processing program, like when it serial read such as "1" it do stuff like play a mp3 file.
Here is the code I started with, so I will when it serial read 1 it play the mp3 file:
- import ddf.minim.*;
- import processing.serial.*;
- Serial port;
- AudioPlayer PVY;
- Minim minim;//audio context
- void setup()
- {
- size(400, 400);
- minim = new Minim(this);
- PVY = minim.loadFile("PVY.mp3", 2048);
- PVY.play();
- port = new Serial(this, "COM3", 9600);
- port.bufferUntil('\n');
- }
- void draw()
- {
- background(255, 0, 0);
- }
- void stop()
- {
- PVY.close();
- minim.stop();
- super.stop();
- }