feliciayoon

Untitled

Sep 25th, 2017
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1.  
  2.  
  3. void setup ()
  4. {
  5. pinMode (A0, INPUT);
  6. pinMode (7, OUTPUT);
  7. Serial.begin(9600);
  8. }
  9.  
  10.  
  11. void loop ()
  12. {
  13. int ldrvalue = analogRead(A0);
  14. Serial.println(ldrvalue);
  15. if (ldrvalue > 500)
  16. {
  17. digitalWrite(7,HIGH);
  18. tone (3, 399, 350);
  19. delay (50);
  20. }
  21. else
  22. {
  23. digitalWrite(7, LOW);
  24. noTone(3);
  25. delay(50);
  26. }
  27. }
Add Comment
Please, Sign In to add comment