Advertisement
Guest User

Untitled

a guest
Dec 5th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. import lejos.hardware.Brick;
  2. import lejos.hardware.Button;
  3. import lejos.hardware.Sound;
  4. import lejos.hardware.motor.Motor;
  5.  
  6. public class Sirens extends Thread {
  7.  
  8. public Brick myEV3;
  9. public boolean siren = false;
  10.  
  11. public Sirens(Brick myEV3) {
  12. this.myEV3 = myEV3;
  13. }
  14.  
  15. public void run() {
  16.  
  17. while(true) {
  18.  
  19. if(!siren) {
  20. Button.LEDPattern(0);
  21. Button.LEDPattern(-1);
  22. }
  23.  
  24. while(siren) {
  25.  
  26. Button.LEDPattern(5);
  27.  
  28. Sound.setVolume(1);
  29.  
  30. Sound.playTone(440, 500);
  31. Sound.playTone(300, 500);
  32. /*
  33. Sound.playTone(440, 250);
  34. Sound.playTone(440, 250);
  35. Sound.playTone(392, 250);
  36. Sound.playTone(440, 250);
  37. try { Thread.sleep(200); } catch (Exception e) {}
  38. Sound.playTone(293, 250);
  39. try { Thread.sleep(200); } catch (Exception e) {}
  40. Sound.playTone(293, 250);
  41. Sound.playTone(440, 250);
  42. Sound.playTone(587, 250);
  43. Sound.playTone(554, 250);
  44. Sound.playTone(440, 250);
  45. */
  46. //try { Thread.sleep(2000); } catch (Exception e) {}
  47.  
  48. }
  49. }
  50. }
  51.  
  52. synchronized void setBoolean(boolean val) {
  53. this.siren = val;
  54. }
  55.  
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement