Arduino Tinkercad Simple Servo Circuit

This will guide you through making a servo circuit and Arduino program in using tinkercad.com.  Sample circuit and program are included below.

Click here for a video description of this assignment.

Click here for a video description of the servo circuit and Arduino program.

Click here to follow the instructions to turn in your Tinkercad circuit.  You can’t just send me the link.

Tinkercad provides a standard servo (it sweeps from left to right, right to left, in a half-circle).  These are often used for steering an RC car or plane.

Your program should:
-include your first and last name as a comment on the first line like this //Rod Milstead
-contain code required to move a standard servo (just retype the code from the sample below).
-move the servo arm (the cross-shaped attachment) from left (0) to 45 degress (45) to right (90) with a two second delay between each move.  NOTE – you have to modify the code below to make this happen.  

Here’s a closeup of REAL servo wiring – the colors code is:
white wire – from pin2 to orange servo wire
red wire – from 5volt on breadboard to red servo wire
blue wire – from ground on breadboard to brown servo wire

You may copy/paste everything below the horizontal line into your program:


#include <Servo.h> //this is the servo library and must be included in your program
Servo servo1; //assigns the variable servo1 to your servo

void setup()
{
servo1.attach(2);//attaches the servo to pin 2 on the Arduino
}

void loop()
{
servo1.write(0);//for a standard servo, 0 spins all the way to left
delay (2000);
servo1.write(90);//for a standard servo, 90 stops in the middle of the sweep
delay (2000);
servo1.write (180);//for a standard servo, 180 spins all the way to right
delay (2000);
}