/*
Arduino Starter Kit example
Project 5 - Servo Mood Indicator
This sketch is written to accompany Project 5 in the Arduino Starter Kit
Parts required:
- servo motor
- 10 kilohm potentiometer
- two 100 uF electrolytic capacitors
created 13 Sep 2012
by Scott Fitzgerald
https://store.arduino.cc/genuino-starter-kit
This example code is part of the public domain.
*/// include the Servo library
#include<Servo.h>ServomyServo;// create a servo object
intconstpotPin=A0;// analog pin used to connect the potentiometer
intpotVal;// variable to read the value from the analog pin
intangle;// variable to hold the angle for the servo motor
voidloop(){potVal=analogRead(potPin);// read the value of the potentiometer
// print out the value to the Serial Monitor
Serial.print("potVal: ");Serial.print(potVal);// scale the numbers from the pot
angle=map(potVal,0,1023,0,179);// print out the angle for the servo motor
Serial.print(", angle: ");Serial.println(angle);// set the servo position
myServo.write(angle);// wait for the servo to get there
delay(15);}