Advertisement
jpglickwebber

Buzzer Exercises

Feb 21st, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. 1.
  2. void setup() {
  3. for(int i=1000; i<=10000; i+=1000){
  4. tone(8, i, 200);
  5. delay(200);
  6. noTone(8);
  7. delay(200);
  8. }
  9. }
  10.  
  11. void loop() {
  12. // put your main code here, to run repeatedly:
  13.  
  14. }
  15.  
  16. 2.
  17. void setup() {
  18. pinMode(9, OUTPUT);
  19. for(int i=1000; i<=10000; i+=1000){
  20. tone(8, i, 200);
  21. digitalWrite(9, LOW);
  22. delay(200);
  23. noTone(8);
  24. digitalWrite(9, HIGH);
  25. delay(200);
  26. }
  27.  
  28. }
  29.  
  30. void loop() {
  31. // put your main code here, to run repeatedly:
  32.  
  33. }
  34.  
  35. 3.
  36. void setup() {
  37. pinMode(9, OUTPUT);
  38. pinMode(13, OUTPUT);
  39. int sw=1;
  40. for(int i=1000; i<=10000; i+=1000){
  41. tone(8, i, 200);
  42. if(sw==1){
  43. digitalWrite(9, LOW);
  44. digitalWrite(13, HIGH);
  45. sw=0;
  46. }
  47. else{
  48. digitalWrite(9, HIGH);
  49. digitalWrite(13, LOW);
  50. sw=1;
  51. }
  52. delay(200);
  53. noTone(8);
  54. delay(200);
  55. }
  56.  
  57. }
  58.  
  59. void loop() {
  60. // put your main code here, to run repeatedly:
  61.  
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement