Go Down

Topic: One sound for one Push Button (Processing to Arduino) (Read 477 times) previous topic - next topic


Hey, i'm working on a project that requires me to have sound play from processing when i am pressing down a button in Arduino and have it turn off and be silent when i take my finger off the button.

at the moment i can get the song to play when i'm holding the button down but when i'm not pressing it there is a loud noise in the background and i can't figure out how to fix it.

the answer might be simple and i'm just not experienced enough to see it but help would really be great, here's the code:

import processing.serial.*;

import cc.arduino.*;

import ddf.minim.*;
Minim minim;
AudioPlayer groove;
Arduino arduino;

int button = 2;

void setup()
  size(512, 200, P3D);
arduino = new Arduino(this, Arduino.list()[0], 57600);
  minim = new Minim(this);
  groove = minim.loadFile("marcus_kellis_theme.mp3");
  arduino.pinMode(button, Arduino.INPUT);

void draw()
  if (arduino.digitalRead(button) == Arduino.LOW )
  if (arduino.digitalRead(button) == Arduino.HIGH )
  } else {
  if (arduino.digitalRead(button) == Arduino.HIGH )
void stop()
  // always close Minim audio classes when you are done with them
  // always stop Minim before exiting.

Go Up