Advertisement
Guest User

Arduino Sound Board

a guest
Oct 20th, 2017
1,233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.49 KB | None | 0 0
  1. int bPins[3] = {2, 3, 4}, bStatuses[4], i, buzzPin = 8;
  2.  
  3. void setup() {
  4.   for (i = 0; i <= 2; i++) {
  5.     pinMode(bPins[i], INPUT);
  6.   }
  7.   pinMode(buzzPin, OUTPUT);
  8. }
  9.  
  10. void loop() {
  11.   for (i = 0; i <= 2; i++) {
  12.     bStatuses[i] = digitalRead(bPins[i]);
  13.   }
  14.  
  15.   if (bStatuses[0] == HIGH) {
  16.     tone(buzzPin, 1000, 300);
  17.   }
  18.   else if (bStatuses[1] == HIGH) {
  19.     tone(buzzPin, 1100, 300);
  20.   }
  21.   else if (bStatuses[2] == HIGH) {
  22.     tone(buzzPin, 1200, 300);
  23.   }
  24.   delay(100);
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement