RAPPAHANNOCK COMMUNITY COLLEGE STEM CAMP
  • Home
  • 2021 STEM Camp (HS)
    • PreAcademy prep
    • Day 1: Basics, Lights, and Temperature Sensor >
      • Day 1 Supplement: Measure Temperature
      • Day 1 Supplement: IR Temp Sensor
      • Day 1 Supplement: Identifying Resistors
      • Supplement: Controlling Buttons
      • Supplement: Controlling A Servo
    • Day 2: Measuring Pulse >
      • How the body absorbs light
      • Day 2 Supplement: IR Light Proximity Sensor
      • Day 2 Supplement: Motion Sensor
      • Code to start later on plotter
    • Day 3 Supplement: OLED Screen Basics >
      • Display Screen Temperature
      • IR Temp Sensor And Screen
      • Scrolling Screen Graph
    • Day 4: Finishing up/Show >
      • Pictures to OLED
      • BPM Pulse Sensor
      • Multimeter
  • Shared Google Folder
  • The Teachers
  • Archive
    • Pictures from prior years
    • 2021 STEM Camp (MS) >
      • Home (2021)
      • PreAcademy prep
      • Day 1: Basics, Lights, and Temperature Sensor >
        • Day 1 Supplement: Identifying Resistors
        • Day 1 Supplement: Measure Temperature
        • Day 1 Supplement: IR Light Proximity Sensor
      • Day 2: Ultrasound >
        • Day 2 Supplement: IR Temp Sensor
        • Day 2 Supplement: Controlling A Servo
      • Day 3: Measuring Pulse >
        • Day 3 Supplement: Motion Sensor
      • Day 4: OLED Screen Basics >
        • Temperature Screen Display
        • IR Temp Sensor And Screen
      • Day 5 Friday: Finishing up/Show
    • 2020 STEM Camp >
      • Home (2020)
      • The 2020 Teachers
      • PreAcademy prep
      • Day 1 Monday: Basics and Lights >
        • Day 1 Supplement Activity
      • Day 2 Tuesday: Servos >
        • Day 2 (Suppliment Activities)
      • Day 3 Wednesday: Making an ECG/EKG! >
        • Day 3 (Supplement Page)
      • Day 4 Thursday: Controlling Servos with EMG >
        • Day 4 Supplemental Activity
      • Day 5 Friday: Finishing up/Show >
        • Unused lessons/content
    • 2018 Lessons >
      • Day 1: Basic Coding
      • Day 2: Motors
      • Day 3: Build Robot Claw
      • Day 4: Saving Positions
      • Day 5: Presentations
    • 2017 Camp >
      • Day 1 (Monday)
      • Day 2: Multicolor LED and Keypad
      • Day 3: Servo and Keypad
      • Day 4: Multiple Motors/Stepper Motor
      • Day 5: Presentations
    • Pictures archive for lessons (some graphic images)
  • Contact Us!

​Controlling ​Servo Motors 


The Supplies Needed


Arduino and USB Cord
Picture
Servo Motor  & Screws
Picture
Picture
Mini Screwdriver
Picture
Jumper Wires 
Picture

Trying out the Servo (1st activity)

We first have to learn how servos work. 
Step 1) Wire up your servo like this. 
1) The brown/black wire goes to GND
2) The red wire goes to 5V
3) The last wire goes to pin 9

(Note, the last wire could be several different colors) 

You can actually plug your servo's orange cord to any pin, just make sure to type that pin number in myservo.attach(#)  where # is what you plugged in. Notice the example picture is plugged into 9? 
Picture

You will need extra wires to plug the servo to the Arduino. This is what that looks like. 

Try to match colors like black to black, etc.
Picture

The Code

Type in the code below. Remember that text after //  are just comments. You do not need to type the // or what comes after them. They are just there to tell you what that line of code does.

Tip: The # symbol for #include is made by pushing shift and 3 together. 
Picture
Step 2) This code uses the <  >  symbols. Those are next to the m key.
To get the < symbol, hold shift and the , key. To get the > symbol, hold shift and the . key


Step 3) Validate the code like yesterday's activity using the check box button the upper left. Here is a link if you need a reminder: https://www.rcccamp.org/day-1-monday-basics-and-lights.html

Step 4) Did you get an error? If so go through the checklist: 
    a) Are all the colored parts in this picture colored in your code?
    b) Check CaPiTaL letters.
    ​c) You may have forgotten a ;
    d) You may have forgotten a parenthesis ( or )
    e) Did you type the curly brackets?  {   }    

                             
​If you get no error, then you can move on.


Step 5) Upload the code using the right arrow symbol (top left) 
      *remember that "problem uploading to board" means you have to change your port. 
        to do that go to: tools, port, and select Arduino


Step 6) Is it working? If so, that's cool! Save your work! 
       *If it is not working, a common  thing is that your wires have some glue stuck on the metal ends. Use your finger nails             to rub any glue off of the wires you are using. 

Once you get it to work, feel free to play with the numbers on the code and re-upload it to see how those numbers effected the servo.  

Use a screwdriver to screw a lever into your servo. 
Picture
Picture

Servo Moves If. How to add a requirement to move. 

If/else statements are really powerful. That is because if you do something, you can make something else happen. Otherwise, nothing happens. Let's set up one of the most basic if/else statements. If a button is pushed, make the servo move. If it is not pressed, go or stay in the default location. 
Powered by Create your own unique website with customizable templates.
  • Home
  • 2021 STEM Camp (HS)
    • PreAcademy prep
    • Day 1: Basics, Lights, and Temperature Sensor >
      • Day 1 Supplement: Measure Temperature
      • Day 1 Supplement: IR Temp Sensor
      • Day 1 Supplement: Identifying Resistors
      • Supplement: Controlling Buttons
      • Supplement: Controlling A Servo
    • Day 2: Measuring Pulse >
      • How the body absorbs light
      • Day 2 Supplement: IR Light Proximity Sensor
      • Day 2 Supplement: Motion Sensor
      • Code to start later on plotter
    • Day 3 Supplement: OLED Screen Basics >
      • Display Screen Temperature
      • IR Temp Sensor And Screen
      • Scrolling Screen Graph
    • Day 4: Finishing up/Show >
      • Pictures to OLED
      • BPM Pulse Sensor
      • Multimeter
  • Shared Google Folder
  • The Teachers
  • Archive
    • Pictures from prior years
    • 2021 STEM Camp (MS) >
      • Home (2021)
      • PreAcademy prep
      • Day 1: Basics, Lights, and Temperature Sensor >
        • Day 1 Supplement: Identifying Resistors
        • Day 1 Supplement: Measure Temperature
        • Day 1 Supplement: IR Light Proximity Sensor
      • Day 2: Ultrasound >
        • Day 2 Supplement: IR Temp Sensor
        • Day 2 Supplement: Controlling A Servo
      • Day 3: Measuring Pulse >
        • Day 3 Supplement: Motion Sensor
      • Day 4: OLED Screen Basics >
        • Temperature Screen Display
        • IR Temp Sensor And Screen
      • Day 5 Friday: Finishing up/Show
    • 2020 STEM Camp >
      • Home (2020)
      • The 2020 Teachers
      • PreAcademy prep
      • Day 1 Monday: Basics and Lights >
        • Day 1 Supplement Activity
      • Day 2 Tuesday: Servos >
        • Day 2 (Suppliment Activities)
      • Day 3 Wednesday: Making an ECG/EKG! >
        • Day 3 (Supplement Page)
      • Day 4 Thursday: Controlling Servos with EMG >
        • Day 4 Supplemental Activity
      • Day 5 Friday: Finishing up/Show >
        • Unused lessons/content
    • 2018 Lessons >
      • Day 1: Basic Coding
      • Day 2: Motors
      • Day 3: Build Robot Claw
      • Day 4: Saving Positions
      • Day 5: Presentations
    • 2017 Camp >
      • Day 1 (Monday)
      • Day 2: Multicolor LED and Keypad
      • Day 3: Servo and Keypad
      • Day 4: Multiple Motors/Stepper Motor
      • Day 5: Presentations
    • Pictures archive for lessons (some graphic images)
  • Contact Us!