Advertisement
Guest User

Untitled

a guest
Dec 6th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. /*Cameron Saunders
  2. * Digital Futures
  3. * Escape Room Puzzles Assignment
  4. * Date: 2019-12-03
  5. */
  6.  
  7. //Include Servo
  8. #include <Servo.h>
  9.  
  10. //Declare a servo using Servo servo1;
  11. Servo servo1;
  12.  
  13.  
  14. void setup() {
  15. // set pin 9 as a servo output pin | servo1.attach(9)
  16. servo1.attach(9);
  17. }
  18.  
  19. void loop() {
  20. int lightValue = analogRead(A0);
  21. // sync the light readings to the angle possible by the servo motor.
  22. lightValue = map (lightValue, 0, 1023, 0, 300);
  23. // Controls the servo motor based on the light value that is being read.
  24. servo1.write (lightValue);
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement