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!

Day 2: Tuesday June 23, 2020
​Servos and Potentiometers

Materials needed for today's activity. 

Picture
Picture
Picture
Picture
Picture

Trying out the Servo (1st activity)

We first have to learn how servos work. 
Step 1) Wire up your servo like this picture. 
*The brown/black wire goes to GND, the red wire goes to 5V and 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
Wire up your servo into your Arduino board like the picture above. 
Yellow* into pin 9, black/brown into Gnd (aka - or ground), and red into the 5V (+)
*
(Note, this wire could be several different colors, but yellow is just used in the picture) 
You will need extra wires to plug the servo into the Arduino. This is what that looks like. 

Try to match colors like black to black and red to red.

Picture
Step 2) Type in the code below.     
* // 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 at the same time 
Picture
This code uses the <  >  symbols. Those are next to the m key on your keyboard.
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 checkpoints from yesterday: 
    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) Plug in your board. 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 some of the numbers on the code and
re-upload it to the board to see how those numbers effected the servo.  

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

How to control more than one Servo? (2nd activity)

You will need to wire up your servo first. Do it like this picture

Notice the servos in this picture are in 10 and 11. You may need to change the code or the pins they are connected to in order to get your servos to work. 

Picture
How to add another servo to your code: 
1)   At the top of your code, just below “Servo myservo”, type in Servo myservo2; 
         *The “2” tells your code that you have a second servo now
2) In the void setup section, type the following below the first attach:
        myservo2.attach(10);        *this attaches the 2nd servo to pin 10 
3) In the void loop section, type the following below myservo:
        myservo2.write(pos);        *this tells the 2nd servo to move  to the position  

You can follow these steps again to add as many servos as you want later if you have time. 

Here is the code for what your 2 servo control code might look like. 
Picture
If you want your second servo to go to different positions than your first you may need to declare a different integer than pos and use that instead. Directions below
Notice in your servo code that the positions go from =0 to 180 in steps of + and - 1. That is what these lines of code do. 

We can change these numbers to make it move differently. Try it out and see what happens. 

180 means 180 degrees, or 1/2 a circle. 
Picture
Here an example. Try changing 180 to 90 instead. What does that do? 

WARNING: Servos usually do not go more than 180 degrees or 1/2 a circle. If you put in more than 180, you may break your servo. 

Controlling servos with Input (3rd activity)

​The servo sweeping back and forth does not help much if we want to control exactly where a robot will go. 

We need to add something that is called an "input", inputs you control. A potentiometer is good for this. 
Here is the picture of what yours looks like. They can be in your kit bag or the black box in the kit. 

Turning it changes the value it gives and we can tell the computer how to use this data. 

Someday you may want to wire up many of these, so we should make an easy to change variables to set what where servos are plugged into the board. 
Picture
Here are the steps to use the knob
Step 1) Wire up your Arduino like this picture using the breadboard.

Note that there are 8 wires. 
3 for the servo
3 for the
potentiometer
2 going from the 5 V and GND to the board

Step 2) Plug in your Arduino with the Blue USB Cord

Step 3) Type in this code below
Picture
Just to clarify, our potentimeter is fatter than the main picture. Ours skips a hole between the pins. 
Picture
Picture
Picture
Step 4) Did you get an error? If so go through the checkpoints from yesterday: 
     1) Are all the colored parts in this picture colored in your code?
     2) Check CaPiTaL letters.
​     3) You may have forgotten a ;
     4) You may have forgotten a parenthesis ( or )
     5) 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 in the upper left. 

Step 6) Is it working? Move the knob back and forward to see if the knob moves the servo.
If so, that's cool. Make it do a little dance and save your work! 

Start building your robot hand. 

Watch this video if you need help building your robot hand. 
Here are links to the two different robot hands you may have gotten for camp. 

Green Hand: https://www.amazon.com/4M-3774-Robotic-Hand-Kit/dp/B005MK0OPO/ref=sr_1_2?dchild=1&keywords=robotic+hand&qid=1591194220&sr=8-2


Purple hand: https://www.amazon.com/Tara-Toys-STEM-Projects-Robotic/dp/B07GRGLB8N/ref=sr_1_15?dchild=1&keywords=robot+hand&qid=1592926434&sr=8-15
​
Picture
Picture

Superglue your servo motors to your robot hand. 

After you build your robot hand, super glue your survos to your robot hand. 
Here are the steps

Step 1: Put super glue where you want the servo on your hand
Picture
Step 2: Place and firmly hold your servo to your frame for about 30 to glue it. 
Picture
Step 3: Put super glue on the servo arm. 
Picture
Step 4: Get one of the finger pullers and firmly hold it to the servo arm for about 30 seconds. 
Picture
A friendly tip for wire management: 

Put a line of super glue down the inner crevice of the robot hand and glue the servo wires to the inside of the robot frame. 

Remember to hold your wires down for about 30 seconds for the glue to set. 

Picture
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!