From 908ce76456e0b0a097139d21e3cfb00c216946df Mon Sep 17 00:00:00 2001 From: aryan-bansal-eng <59635033+aryan-bansal-eng@users.noreply.github.com> Date: Sun, 9 Feb 2020 18:32:02 -0800 Subject: [PATCH] Add files via upload --- Servo.ino | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Servo.ino diff --git a/Servo.ino b/Servo.ino new file mode 100644 index 0000000..a93f7d1 --- /dev/null +++ b/Servo.ino @@ -0,0 +1,18 @@ +#include + +Servo servo; +int potentioPin = 0; //analog pin that connects to the potentiometer +int val = 0; +void setup() +{ + servo.attach(9); //attach servo on pin 9 on arduino +} + +void loop() +{ + val = analogRead(potentioPin); + val = map(val, 0, 1023, 0, 180); + servo.write(val); + Serial.println(val); + delay(15); +}