-
-
Save JeffersGlass/6a78ebd8bb5141ae5a250a4d08f0ea38 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Servo.h> | |
Servo myservo; // create servo object to control a servo | |
int potpin = 0; // analog pin used to connect the potentiometer | |
int val; // variable to read the value from the analog pin | |
void setup() { | |
myservo.attach(9); // attaches the servo on pin 9 to the servo object | |
randomSeed(analogRead(A1)); | |
} | |
void loop() { | |
val = random(180); // Creates a random value between 0 and 180 degrees | |
myservo.write(val); // sets the servo position according to the scaled value | |
delay(random(1000, 3000); // Wait for between 1 and 3 seconds | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment