inByte == "A" play video

edited November 2016 in Arduino

Hi, I have a sketch which listens to arduino and when it reads incoming bytes then plays sounds. I am having hard time changing that to play video instead. Could you please advice me.

import processing.serial.*;
import ddf.minim.*;
Minim minim;
AudioPlayer player;
int loopcount;

int bgcolor;                 // Background color
int fgcolor;                 // Fill color
Serial myPort;                       // The serial port
int[] serialInArray = new int[3];    // Where we'll put what we receive
int serialCount = 0;                 // A count of how many bytes we receive
int xpos, ypos;                  // Starting position of the ball
boolean firstContact = false;        // Whether we've heard from the microcontroller

void setup() {
  size(256, 256);  // Stage size
  noStroke();      // No border on the next thing drawn
  minim = new Minim(this);


  String portName = Serial.list()[0];
  //myPort = new Serial(this, "/dev/cu.usbmodem1510721", 9600);
  myPort = new Serial(this, "/dev/cu.HC-05-DevB", 9600);

void draw() {
  // Draw the shape

void serialEvent(Serial myPort) {

  int inByte =;

  if (firstContact == false) {
    if (inByte == 'A') { 
      player = minim.loadFile("drumgroove_3.wav");
      // ask for more

    if (inByte == 'F'){
      player = minim.loadFile("sound_7.mp3");;

     if(inByte == 'B'){
player = minim.loadFile("sound_2.mp3");;
    if (inByte == 'C'){
      player = minim.loadFile("sound_6_converted.wav");
      loopcount = 3;

    if (inByte == 'D'){
      player = minim.loadFile("sound_4.mp3");;

    if (inByte == 'E'){
      player = minim.loadFile("sound_5.mp3");;



    • All resources should preferably be loaded before draw() starts.
    • Any hardware resource needs to call some dispose method when's not needed anymore.
    • Java can't GC such resources alone! For Minim, such method is called stop().
    • Forgetting to do so causes serious memory leakage. Sometime it even hogs the CPU! :-SS
Sign In or Register to comment.