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!

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