Skip to content

Instantly share code, notes, and snippets.


JeffersGlass/servoRandom.ino Secret

Created Apr 5, 2020
What would you like to do?
#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
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
You can’t perform that action at this time.