SUMMER STEM-HEALTH CAMP
  • Home
  • 2025 RCC Camp
    • Day 1: Basic Coding >
      • Button Control
      • Multicolor LED
      • Fading multicolor led
      • Melody (sound)
    • Day 2: Servos and Potentiometers >
      • DC Motor
      • Ultrasound
      • Potentiometer and Motors
      • 2 servo control >
        • Analog Stick Control
      • PIR Motion Sensor
      • IR Light Proximity Sensor
    • Day 3 Making an ECG/EKG! >
      • ECG/EKG health lesson
      • OLED Screen Basics
      • Pictures to OLED
      • BPM on OLED
    • Day 4: Measuring Pulse >
      • Scrolling Screen Graph
      • How the body absorbs light
      • Screen Pictures
      • IR Temp Sensor And Screen
    • Day 5: Finishing up/Show >
      • IR Light Proximity Sensor
      • PIR Motion Sensor
      • CO2 Sensor
      • Ultrasound distance sensor
  • The Teachers
  • Our Partners
  • Archive
    • 2024 Health-STEM Coding Camp >
      • Home (2024)
      • The Teachers
      • Day 1: Basics and Lights
    • 2024 Coding/Robotics Camp >
      • Day 1: Basic Coding >
        • Saving your codes
        • Engineering design
      • Day 2 Servos >
        • 2 Servos, one potentiometer
        • Multicolor LED >
          • Fading multicolor led
    • Pictures from prior years
    • 2023 3D Design Camp >
      • Day 1: 2D design
      • Day 2: 3D design basics
      • Day 3: Constraints
    • 2023 Health-STEM Coding Camp >
      • PreAcademy prep
      • Day 1: Basics and Lights >
        • Multicolor LED
        • Button Control
      • Day 2: Ultrasound >
        • Ultrasound Health Lesson
        • Supplement Melody
        • Supplement: Servo >
          • Potentiometer and Motors
          • 2 servo control
      • Day 3: Measuring Pulse >
        • How the body absorbs light
        • OLED Screen Basics >
          • Scrolling Screen Graph
      • Day 4 Making an ECG/EKG! >
        • ECG Health Lesson
        • Pictures to OLED
        • BPM on OLED
      • Day 5: Finishing up/Show
    • 2021 STEM Camp (HS) >
      • The Teachers (2021)
      • 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 A Servo
      • Day 2: Measuring Pulse >
        • How the body absorbs light
        • IR Light Proximity Sensor
        • PIR Motion Sensor
      • Day 3 Supplement: OLED Screen Basics >
        • Display Screen Temperature
        • Scrolling Screen Graph
      • Day 4: Finishing up/Show
    • 2021 STEM Camp (MS) >
      • 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
    • 2020 STEM Camp
    • 2018 Lessons
    • 2017 Camp
  • Contact Us!
Picture

Materials needed for today's activity. 

Picture
Picture
Picture
Picture
Picture

Trying out the Servo 

Step 1) Wire up your servo like the picture. 
  • The dark wire goes to GND
  • The red wire goes to 5V
  • The signal wire wire goes to pin 9. 
(Note, the last wire could be several different colors, it's yellow in the picture) 

You could put the servo's  last cord in  any pin, just make sure you change that pin number in myservo.attach(#),  where # is what you plugged in. In the example picture, it is plugged into 9. 
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.
 
Picture
Tip: The # symbol is made by pushing shift and 3 at the same time

The  <  >  symbols are next to the m key on your keyboard.
(shift and the , key or hold shift and the . key)


Step 3) Validate the code using the check box button the upper left.

Step 4) Did you get an error? If so go through the checkpoints from yesterday. ​If you get no error, then you can move on.
  • Check CaPiTaL letters
  • You may have forgotten a ;
  • You may have forgotten a parenthesis ( or )
  • Did you type the curly brackets?  {   }    
                         
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.

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 will need to declare a different number than pos and use that instead. Directions below
Notice in these lines of your servo code that the positions go from = 0 to 180 in steps of + and - 1.

Changing these numbers would make it move to a different position. Try it out and see what happens. 

180 means 180 degrees (1/2 a circle) 
Picture
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 

​What if we want a person to be able to change where the servo goes with a physical input, we need to add something that is called an "input" (inputs you control). A potentiometer is good for this. 

Here is a picture of one. 

Turning it changes its output value. We can tell the computer how to use this data. 

Picture
Just to clarify, our potentimeter is fatter than the wiring picture shows. Ours skips a hole between the pins. 
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
Picture
Step 4) Did you get an error? If so go through these checkpoints:
     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! 

After you get through today's main activity and show your teacher that you got your servo on a base, you can move to a supplemental activity. 

Proudly powered by Weebly
  • Home
  • 2025 RCC Camp
    • Day 1: Basic Coding >
      • Button Control
      • Multicolor LED
      • Fading multicolor led
      • Melody (sound)
    • Day 2: Servos and Potentiometers >
      • DC Motor
      • Ultrasound
      • Potentiometer and Motors
      • 2 servo control >
        • Analog Stick Control
      • PIR Motion Sensor
      • IR Light Proximity Sensor
    • Day 3 Making an ECG/EKG! >
      • ECG/EKG health lesson
      • OLED Screen Basics
      • Pictures to OLED
      • BPM on OLED
    • Day 4: Measuring Pulse >
      • Scrolling Screen Graph
      • How the body absorbs light
      • Screen Pictures
      • IR Temp Sensor And Screen
    • Day 5: Finishing up/Show >
      • IR Light Proximity Sensor
      • PIR Motion Sensor
      • CO2 Sensor
      • Ultrasound distance sensor
  • The Teachers
  • Our Partners
  • Archive
    • 2024 Health-STEM Coding Camp >
      • Home (2024)
      • The Teachers
      • Day 1: Basics and Lights
    • 2024 Coding/Robotics Camp >
      • Day 1: Basic Coding >
        • Saving your codes
        • Engineering design
      • Day 2 Servos >
        • 2 Servos, one potentiometer
        • Multicolor LED >
          • Fading multicolor led
    • Pictures from prior years
    • 2023 3D Design Camp >
      • Day 1: 2D design
      • Day 2: 3D design basics
      • Day 3: Constraints
    • 2023 Health-STEM Coding Camp >
      • PreAcademy prep
      • Day 1: Basics and Lights >
        • Multicolor LED
        • Button Control
      • Day 2: Ultrasound >
        • Ultrasound Health Lesson
        • Supplement Melody
        • Supplement: Servo >
          • Potentiometer and Motors
          • 2 servo control
      • Day 3: Measuring Pulse >
        • How the body absorbs light
        • OLED Screen Basics >
          • Scrolling Screen Graph
      • Day 4 Making an ECG/EKG! >
        • ECG Health Lesson
        • Pictures to OLED
        • BPM on OLED
      • Day 5: Finishing up/Show
    • 2021 STEM Camp (HS) >
      • The Teachers (2021)
      • 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 A Servo
      • Day 2: Measuring Pulse >
        • How the body absorbs light
        • IR Light Proximity Sensor
        • PIR Motion Sensor
      • Day 3 Supplement: OLED Screen Basics >
        • Display Screen Temperature
        • Scrolling Screen Graph
      • Day 4: Finishing up/Show
    • 2021 STEM Camp (MS) >
      • 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
    • 2020 STEM Camp
    • 2018 Lessons
    • 2017 Camp
  • Contact Us!