Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. int sliderReading; //slider reading
  2. int phoReading; //photocell reading
  3. int frequency1;
  4. int frequency2;
  5.  
  6. void setup() {
  7. Serial.begin(9600);
  8. pinMode(8, OUTPUT);
  9. }
  10.  
  11. void loop() {
  12.  
  13. //reading the light sensors
  14. sliderReading = analogRead(A0);
  15. phoReading = analogRead(A1);
  16.  
  17. //mapping each frequency
  18. frequency1 = map(sliderReading, 1, 1023, 100, 500);
  19. frequency2 = map(phoReading, 1, 1023, 100, 500);
  20.  
  21. //change the pitch, putting two frequencies together
  22. tone (8, frequency1 + frequency2);
  23.  
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement