Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. int photocell = A0;
  2. int speaker = 8;
  3. float freq = 0;
  4.  
  5. void setup() {
  6. // put your setup code here, to run once:
  7. pinMode(speaker, OUTPUT);
  8. Serial.begin(9600);
  9. }
  10.  
  11. void loop() {
  12. // put your main code here, to run repeatedly:
  13. int photoread = analogRead(photocell);
  14. Serial.println(photoread);
  15. freq = map(photoread, 0, 1023, 100, 1000);
  16.  
  17. /*
  18. * Default - 350 - 650
  19. * R1 covered- 100-350
  20. * R2 covered- 650 - 1000
  21. */
  22. tone(speaker, freq, 10);
  23.  
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement