Advertisement
sirik13

code in work for final project

May 18th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. int notes [] = {262,294,330,349,392,440};
  2.  
  3. void setup() {
  4. Serial.begin(9600);
  5.  
  6. }
  7.  
  8. void loop() {
  9.  
  10. int keyVal = analogRead (A0);
  11. Serial.println(keyVal);
  12.  
  13. if(keyVal == 1023) {tone(8, notes[0]);
  14. }
  15. else if(keyVal >= 1000 && keyVal <= 1020) {tone(8, notes[1]);
  16. }
  17. else if(keyVal >= 50 && keyVal <= 60) {tone(8, notes[2]);
  18. }
  19. else if(keyVal >= 330 && keyVal <= 345) {tone(8, notes[3]);
  20. }
  21. else if(keyVal >= 100 && keyVal <= 110) {tone(8, notes[4]);
  22. }
  23. else if(keyVal >= 505 && keyVal <= 515) {tone(8, notes[5]);
  24. }
  25. else if(keyVal >= 990 && keyVal <= 1010) {tone(8, notes[6]);
  26. }
  27.  
  28. else{noTone(8);
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement