Guest User

Untitled

a guest
Jun 22nd, 2014
401
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import ddf.minim.*;
  2. import processing.serial.*;
  3. import cc.arduino.*;
  4.  
  5. Arduino arduino;
  6. int laserReceiverPin = 2;
  7. int laserPin = 3;
  8. AudioPlayer alarm;
  9. Minim minim;
  10.  
  11. void setup()
  12. {
  13.   //println(Arduino.list());
  14.   arduino = new Arduino(this, Arduino.list()[1], 57600);
  15.  
  16.   arduino.pinMode(laserReceiverPin, Arduino.INPUT);
  17.   arduino.pinMode(laserPin, Arduino.OUTPUT);
  18.  
  19.   arduino.digitalWrite(laserPin, Arduino.HIGH);
  20.  
  21.   minim = new Minim(this);
  22.   alarm = minim.loadFile("bell.wav");
  23. }
  24.  
  25. void draw()
  26. {
  27.  
  28.   if (millis() > 5000 && arduino.digitalRead(laserReceiverPin) == Arduino.LOW && alarm.isPlaying() == false){
  29.     alarm.play();
  30.     delay(alarm.length());
  31.     alarm.rewind();
  32.     alarm.pause();
  33.     println(millis() + " " + "ding");
  34.   }
  35.  
  36. }
  37.  
  38. void stop(){
  39.   minim.stop();
  40.   super.stop();
  41. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×