Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Cameron Saunders
- * Digital Futures
- * Escape Room Puzzles Assignment
- * Date: 2019-12-03
- */
- //Include Servo
- #include <Servo.h>
- //Declare a servo using Servo servo1;
- Servo servo1;
- void setup() {
- // set pin 9 as a servo output pin | servo1.attach(9)
- servo1.attach(9);
- }
- void loop() {
- int lightValue = analogRead(A0);
- // sync the light readings to the angle possible by the servo motor.
- lightValue = map (lightValue, 0, 1023, 0, 300);
- // Controls the servo motor based on the light value that is being read.
- servo1.write (lightValue);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement