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!

2017 STEM Camp Lessons

This is the 2017 STEM Camp lesson Archive.
Click on the links below for the day you would like to visit. 

Day 1: Controlling lights
Day 2: Multicolor light and keypad 
Day 3: Servos
Day 4: Motors
Day 5: Presentation and catch up
Picture

Blink

You will start by getting your arduino to do something simple first
void setup() { // the setup function runs once when you press reset or power the board
  pinMode(LED_BUILTIN, OUTPUT); // initializes digital pin LED_BUILTIN as an output.
}
void loop() { // loop functions run over and over again forever
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second
}
Once you get your onboard LED to work start playing around with the code to see what changing it does. Try something creative with it to get it to do something cool. 

Reading Resistors

Before we can continue, we have to teach how to read resistors. 
Picture
We will do this one together
Picture
Now teachers will hand out one to students at a time from a bag to see if they can figure it out. 

Turning off-board LEDs on and off 

You are now going to try and get LEDs to work using the bread board. You will also see how resistors change a circuit. 
Wire up your breadboard as shown below. 
Picture

Swap out a few of the resistors shown and observe how it changes the system. 
Once you have tested it a few times move the 5V wire to a pin and change your blink code to try and figure out how to get your new light to turn on and off. You will need to change the pin used in your code from onboard LED to which ever digital pin you have your wire in. 

Once you get one to light up, test out trying to put some lights in parallel, in the same column, or series, in the same row. See what happens as you try both. 

Turning onboard LED on and off with Button

We will now try to get that onboard LED to blink by using a button. Set up your circuit similar to below
Use the :
  • 10K ohm resistor
Picture
​/* Turns on and off a light emitting diode(LED) connected to digital
 pin 13, when pressing a pushbutton attached to pin 2.*/

// these constants set pin numbers: const is used before int to ensure the value does not change

const int buttonPin=2; //the number of the pushbutton pin
const int ledPin=LED_BUILTIN; //the number of the LED pin 
int buttonState=0; // variable for reading the pushbutton status


void setup() {
pinMode (ledPin,OUTPUT);
pinMode (buttonPin,INPUT);
}
void loop() {
buttonState=digitalRead(buttonPin);
if(buttonState==HIGH){
digitalWrite(ledPin,HIGH);
 }
else{
  digitalWrite(ledPin,LOW);
 }
}

Now we will try and make series and parallel circuits

Parallel
Picture

Series
Picture

Split into groups for your show

By the end of the week you will know how to use, LEDs, multicolor LEDs, Motors, Servos, and Stepper motors. You can plan your animatronic around using those parts

We start today by planning your show and who will make what. You can start making your skits for the show. Design your puppets and what you want to use the lights on for your show.

Multicolor LED

Set up your breadboard similar to as shown and use the 220 resistors for your board. 
Picture
Picture

Getting the colors on (Blinking)

Use the same code that you used to get your regular LEDs on and off and see if you can get them to turn on the Multi color LED's colors. You may have to change the pin numbers used in your code. If you have trouble, you can start with this code below. 
Picture
Now that you got one light on, go ahead and change your code to try and change colors or get two colors on at once. 

Set Colors your own color 

This code is used to set up your led to be multiple colors and brightness at once. 
You change the numbers in the "setColor(255, 0, 0);" part to change what colors your LED makes. 
Picture

Getting the colors to switch

Now that you have gotten the code to work, try adding  the other colors to digitalWrites to get the colors to switch. 
You add this to the loop just like you added delays and more digitalWrites to your blink code. 
Once you get it to work, change the values in the set color part to numbers between 0-255 and see what happens. 
Picture

Getting the colors to fade

See if you can get your RGB LED to fade in and out with this code. Let's see if we can understand it too. 

#define BLUE 3 //We are defining the different colors
#define GREEN 5 //to the different pins 
#define RED 6 // change the numbers to what you have plugged in
​
void setup(){
pinMode(RED, OUTPUT);
pinMode(GREEN, OUTPUT);
pinMode(BLUE, OUTPUT);
digitalWrite(RED, LOW);
digitalWrite(GREEN, LOW);
digitalWrite(BLUE, LOW);
}
int redValue; // define variables
int greenValue;
int blueValue;

void loop(){
#define delayTime 10 // fading time between colors

redValue = 255; // this code starts with red on, choose a value between 1 and 255 to change the color.
greenValue = 0;
blueValue = 0;

for(int i = 0; i < 255; i += 1) { // fades out red bring green full when i=255
redValue -= 1; // makes red dimmer by one each delay time 
greenValue += 1; // makes green brighter by one each delay time 
analogWrite(RED, redValue);
analogWrite(GREEN, greenValue);
delay(delayTime);
}

for(int i = 0; i < 255; i += 1) { // fades out green bring blue full when i=255
greenValue -= 1;
blueValue += 1;
analogWrite(GREEN, greenValue);
analogWrite(BLUE, blueValue);
delay(delayTime);
}

for(int i = 0; i < 255; i += 1) {// fades out blue bring red full when i=255
blueValue -= 1;
redValue += 1;
analogWrite(BLUE, blueValue);
analogWrite(RED, redValue);
delay(delayTime);
 }
}

The Keypad

In order to make things work with your robot when you want you will need to hook up a keypad to control it. We will now make a new arduino file with the keypad code so that we can add code to it as we make things work. 

Set up the keypad as shown to your Arduino. 
Picture
Before we can use the keypad we need to make sure your arduino file has the correct library.
Go to: Sketch- Include Library - Manage Libraries -
Then type Keypad and check if the one by Mark Stanley is installed. If so continue on.
Here is the base code for the keypad
#include <Keypad.h>

const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns

​char hexaKeys[ROWS][COLS] = {
  {'1','2','3','A'},  //define the symbols on the buttons of the keypads
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'*','0','#','D'}
};
byte rowPins[ROWS] = {9, 8, 7, 6}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {5, 4, 3, 2}; //connect to the column pinouts of the keypad

Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS); //initializes Keypad
​
void setup(){
}
 void loop (){
     char customKey = customKeypad.getKey(); 
}

Test if your keypad works! 

Every code you write can be added to work with your keypad by copying each part of your code and moving it to your keypad code. Add the below code into void loop () { }. In the if { } of the below code, put the premade code that you want button x to do in the { }.

if (customKey == 'x'){  //where x is what key you want to press to turn it on or off
  }

Here is my example code to add you your loop to get your onboard LED to turn on or off
If it does not work make sure you check your blink code to make sure you added all the parts

​void loop (){
char customKey = customKeypad.getKey();
if (customKey == '1'){
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
   }
   if (customKey == '2'){
     digitalWrite(LED_BUILTIN, LOW); 
   }
}
See if you can get your multicolor LED to work with the buttons. Setting up all three colors to work by turning on and off with the keypad can make up to 7 colors. Red, Green, Blue, Cyan, Magenta, Yellow, and White. 

Wednesday's Lesson  

Today we are going to learn how to use the servo. It is important to check which pins your code uses matches what pins you plug things into. 
We will then try and get the servo to work with the keypad. 
Over the course of the morning you will also start  building your animatronic and designing your skit.
Your presentation skit should not be longer than 5 minutes.  

Servo sweep

A servo is a motor that moves in steps smoothly and only between certain angles
+- 180 degrees. We will start with a simple code to control a servo to go back and forward.

​Build the circuit below and try out the code below. Play with the delay and the angles in the for loops to see what happens
Picture
Picture

Make your servo move back and forward just a certain amount of degrees.

Picture

Get your servo to move with the keypad

Now we will try to get the servo to move clockwise and counterclockwise by pushing keypad buttons. Use the code you just wrote above that worked and move it to your keypad code. Try to move it yourself but if it does not work you can try  copying what is below to a new page.

​Once you get it, try to change some parts to see how it works. 
#include<Keypad.h>
#include <Servo.h>
Servo myservo;

int pos=90; //we will start the servo at 90 deg
int del=15;    //this is the delay for the functions
const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
int change = 30; //how much the servo goes back and forward
int newPos; //this is a variable used to move the servo to a new position of pos+ or - change

char hexaKeys[ROWS][COLS] = {
  {'1','2','3','A'},  //define the symbols on the buttons of the keypads
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'*','0','#','D'}
};
byte rowPins[ROWS] = {9, 8, 7, 6}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {5, 4, 3, 2}; //connect to the column pinouts of the keypad

Keypad customKeypad=Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);

void setup() {
  myservo.attach(10);   //this is the number that your servo is connected to
  myservo.write(pos); 
}

void loop() {
 char customKey = customKeypad.getKey();
  if (customKey == '8'){
  newPos = pos+change;     //Variable moves pos counterclockwise by x degrees. Default is 30 deg

    for (; pos <= newPos; pos++){ //makes servo go counter clockwise to new newPos
      myservo.write(pos);
      delay (del);
 }
}

   if (customKey == '9'){         //this button will move it backwards
     newPos = pos-change; //Variable moves pos counterclockwise by x degrees. Default is 30 deg

    for (; pos >= newPos && pos>5; pos--){ //makes servo go counter clockwise to new newPos
      myservo.write(pos);
      delay (del);
   }
  }

   if (customKey == '7'){  //this button makes it move back and forward
     for (pos = 90; pos <= 130; pos += 1){
  myservo.write(pos);
  delay(del);
}
for (pos = 130; pos >= 90; pos -= 1){
  myservo.write(pos);
  delay(del);
 }
}  
  
   }
   

Thursday's lesson: The Regular Motor

The regular motor is simple. Just plug the positive into one of the output arduino pins and the negative into the breadboard. Here is a sample code to get the motor to turn on and off. 
 #define Motor A5 //defines "Motor" to use this pin to turn on or off (Change A5 to whatever pin you use) 
void setup() {
pinMode(Motor,OUTPUT); //Defines the pin for the motor on "A5" to be an output
}
void loop() {
  digitalWrite(Motor, HIGH);   //this just turns the motor on
  delay (400);
  digitalWrite(Motor, LOW); //This turns the motor off
  delay (400);
}
Did your motor work? Figure out how you want to use this motor in your device, install it, and play with your code to get it to do what you want. Once you are happy with it, set it up to work with your keypad just like you did to turn LEDs on and off. 
That code will look something like this after defining your motor to use a pin and using a bool to set the state as on or off. Move each of these parts in the right place in your keypad code. 

#define Motor A5 // defines the "Motor" to use this pin to turn on or off
bool motorState=0; //sets the motor to be off as standard

void setup() {
pinMode(Motor,OUTPUT); //Defines the pin for the motor on "A5" to be an output
}

void loop (){
  char customKey = customKeypad.getKey(); 
  if(customKey == '5'){  //This part defines a key to turns the motor on and off
  if (motorState==0){ //if the motor is off (set to 0)
    digitalWrite(Motor, HIGH); //turns it on
    motorState = 1;  //sets the bool to on 
      }
   else if (motorState==1){ //if the motor is on (1)
    digitalWrite(Motor, LOW); //turns it off
    motorState=0; //writes the bool as off so the arduino knows
     }
    }
  }

Now try to connect the motor to working with the keypad

Copy and paste the parts into your working keypad code. 
Figure out how your group will use the motor in your animatronic or skit and install it into your design. The keypad code to make this work looks a lot like getting your onboard LED to work. 

This code is also exactly the same as how to add off-board LED to work with your arduino for your robot. 

How to do more than one Servo. 

If you want to do more than one servo you are going to need to. 
1) Add another servo to your: Servo myservo2;  at the top of your code (you need a different name)
2) Add your second servo to your void setup 
   myservo2.attach(10);  // attaches the servo on pin 10 
   myservo2.write(pos); //Resets the servo to zero degrees
3) Copy your if statements in your keypad code that have your first servo and just change everything that says "myservo" to saying "myservo2" instead

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. 

These steps can be done again to add more servos. 

The Stepper Motor (This is an extra lesson if you get to it)

To find the sample stepper motor codes, open your Arduino IDE and go to
1) File
2) Examples
3) Stepper one rev

Picture
Here is the sample base code
#include <Stepper.h>

const int stepsPerRevolution = 200;  // change this to fit the number of steps per revolution for your motor

Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11); // initialize the stepper library on pins 8 through 11:
// (change as needed) 

void setup() {
  myStepper.setSpeed(60); // set the speed at 60 rpm:
}
void loop() {
  myStepper.step(stepsPerRevolution); // step one revolution  in one direction:
  delay(500);
  myStepper.step(-stepsPerRevolution); // step one revolution in the other direction:
  delay(500);
}

Try and get your stepper to work with your keypad

Once you get it to work on its own, see if you can figure out how to add the code to your keypad so it goes clockwise and counterclockwise by pushing different buttons. See the complete example code in the google doc if you are having problems. 

Figure out how you can incorporate the stepper motor into your animatronics, if you want.  

Friday: It's time to prep for the show! 

Check that all your electronics and code works and then finish building your animatronic. 
Finalize your skit for the show. Your rooms should be cleaned and ready to present by 11:50.
Picture
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!