daily pastebin goal
61%
SHARE
TWEET

Untitled

a guest Feb 21st, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int photo = A0;
  2. int photoVal;
  3.  
  4. float freq_C = 261.63;
  5. float freq_D = 293.66;
  6. float freq_E = 329.63;
  7. float freq_F = 349.23;
  8. float freq_G = 392.00;
  9. float freq_A = 440.0;
  10. float freq_B = 493.88;
  11.  
  12. int noteDur = 500;
  13.  
  14. void setup() {
  15.   // put your setup code here, to run once:
  16.  
  17.   Serial.begin(9600);
  18.  
  19. }
  20.  
  21. void loop() {
  22.   // put your main code here, to run repeatedly:
  23.   photoVal = map(analogRead(photo), 150, 500, 0, 6);
  24.   Serial.println(analogRead(photo));
  25.   switch (photoVal) {
  26.     case 0:
  27.       tone(8, freq_C);
  28.       break;
  29.     case 1:
  30.       tone(8, freq_D);
  31.       break;
  32.     case 2:
  33.       tone(8, freq_E);
  34.       break;
  35.     case 3:
  36.       tone(8, freq_F);
  37.       break;
  38.     case 4:
  39.       tone(8, freq_G);
  40.       break;
  41.     case 5:
  42.       tone(8, freq_A);
  43.       break;
  44.     case 6:
  45.       tone(8, freq_B);
  46.       break;
  47.   }
  48. //  tone(8, photoVal);
  49.   delay(10);
  50.  
  51. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top