Welcome to RCC's Coding and Robotics Camp!
The Middle School Arduino coding and mechatronics camp at King George RCC teaches students the basics of coding, electronics, and electronics. Students will get coding and wiring lessons and then use that knowledge to build and simple mechatronic.
June 3rd to 7th from 9:00 a.m. to 12:30 p.m. at RCC King George Campus.
The software used for this camp is Arduino IDE.
Here is the camp's curriculum timeline:
June 3rd to 7th from 9:00 a.m. to 12:30 p.m. at RCC King George Campus.
The software used for this camp is Arduino IDE.
Here is the camp's curriculum timeline:
Materials needed for today's activity.
Trying out the Servo
We first have to learn how servos work.
Step 1) Wire up your servo like the picture.
*The dark wire goes to GND, the red wire goes to 5V and the last wire to pin 9. (Note, the last wire could be several different colors) You put servo's orange 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. |
*(Note, this wire could be several different colors, but yellow is just used in the 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.
* // 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 is made by pushing shift and 3 at the same time
The < > symbols 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.
The < > symbols 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.
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.
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.
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.
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.
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
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.
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. Turning it changes its output value. We can tell the computer how to use this data. Just to clarify, our potentiometer is fatter than the wiring picture shows. Our potentiometer is fatter than the wiring picture shows. Ours skips a hole between the pins. |
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!
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
Hopefully, you've got an idea on what you want to make for your mechatronic?
What is going to move in your robot? A hand, an arm, a mouth, a leg, something else? Take some time to think about it. The servo acts as the "joint" for the object. It is like your elbow or wrist. Take some time to build a base to put your servo motor on that makes sense. There are a lot of ways to attach the motor to where your
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.
What is going to move in your robot? A hand, an arm, a mouth, a leg, something else? Take some time to think about it. The servo acts as the "joint" for the object. It is like your elbow or wrist. Take some time to build a base to put your servo motor on that makes sense. There are a lot of ways to attach the motor to where your
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.
Supplemental Lessons
Make sure to do the regular day lesson first.
Multicolor LEDHere is a video showing you the basics.
|
|
Set up your breadboard similar to below and use the 220 resistors.
It does not really matter what pins you use for red, green, and blue (RGB) as long as they have the ~ symbol in front of the number like ~11 or ~3 etc.
The ~ symbol by a pin means Pulse Width Modulation. You don't need to know what that is right now, but it helps for the 3 color RGB light.
It does not really matter what pins you use for red, green, and blue (RGB) as long as they have the ~ symbol in front of the number like ~11 or ~3 etc.
The ~ symbol by a pin means Pulse Width Modulation. You don't need to know what that is right now, but it helps for the 3 color RGB light.
Watch this video to get the background for this activity.
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 to the left.
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.
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.
You change the numbers in the "setColor(255, 0, 0);" part to change what colors your LED makes.
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. |
The Regular Motor
The regular motor is simple. You can test if it will work by just plugging in one side to a voltage source and the other side to a ground. The more volts sent to it, the harder it spins. Test it out!
Controlling the motor with Arduino
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" and uses the A5 pin to turn on or off (You can use any A pin)
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);
}
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 if and 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, add that code to your main mechatronic code.
Once you are happy with it, add that code to your main mechatronic code.
Today is mainly a build day. We want you to have time to get something simple mostly built for tomorrow. We can add things to it once the basic structure is done and something on it moves and doesn't break.
After you show your teacher you succeeded in that, you can try some of the supplemental activities. : )
After you show your teacher you succeeded in that, you can try some of the supplemental activities. : )
Adding More Servos to Your Arm
Building your claw!
Each student then does a redesign to incorporate at least 3 servos in the design. Students are taught how to manipulate the premade code for the Arduino servo to assist their build (analog stick code taught). Students then try to get it working in their design.
(after they get the analog stick to work, have them switch the potentiometer and analog stick analog input port and see how that changes how the servos react.) The stick acts like the knob now.
(after they get the analog stick to work, have them switch the potentiometer and analog stick analog input port and see how that changes how the servos react.) The stick acts like the knob now.
Proximity Sensor
IR obstacle sensor - is something in front of me?
The clear LED is an IR lightbulb. The dark bulb is an IR phototransistor. Photoresistors are devices that amplify current more when more light shines on it. The sensor works by emitting light in front of it and then the detector measures the amount of light reflection. The little screw on the board is a variable resistor that you can use to set the detection threshold. If the detector receives enough light, it outputs that something is there!
Plug the sensor into the Arduino. Then point a digital camera, like your cell phone or webcam, at it and see if you can see the light using the camera. Note, only some cameras can see IR. |
The bulb not emitting visible light. It is only emitting a specific wavelength of infrared light (IR)! That means it is not visible to your eye.
|
Look at this picture and video for how this sensor works.
The code!
This sensor gives outputs of either 0 or 1 for if something is close to it or not. This code below will print on or off to the Serial Plotter depending on if something is close to it or not. Type out the code below in Arduino IDE
Turn on a light when close.
We can add to the code in order to have a light turn on when the proximity sensor says something is close. Put a LED's + side with a resistor on pin 13 and put the other side in ground. Add these lines to the code to tell the board that you are going to use the LED_BUILTIN (13) as an output and then write on or off when the sensor goes off or on.
|
Test it, Does it work?
Saving Positions
Wouldn't it be cool to teach your arm how to save positions?
If you are caught up today and want to try, here is how!
Here is a video to show what you can get your robot to do today.
If you are caught up today and want to try, here is how!
Here is a video to show what you can get your robot to do today.
The Code for saving positions for 3 servos
Here is a file to save the code. The code is pictured below it.

simplesavepositions.ino | |
File Size: | 3 kb |
File Type: | ino |
Wiring Diagram
Displaying Text on a Screen. "Hello, World!"
Supplies Needed:
Part 1: Downloading the OLED Library
Open up your Arduino IDE program. Then go to tools and manage libraries to get the following.
Install the "Adafruit SSD1306" library. If it asks you to install other ones for it to work, say yes to getting all of them.
Install the "Adafruit SSD1306" library. If it asks you to install other ones for it to work, say yes to getting all of them.
Part 2: Wiring the OLED Display and Graphics Test
The Wiring.
1) GND to GND 2) VCC to 5 V 3) SCL to pin A5 4) SDA to pin A4 |
Download, verify, and upload this code.
This is a graphics test.
|
Did it work? If not, get help from your teacher.
Part 3) The Code. Writing Text. Hello World!
Type up this code to the right then check it (verify), upload it to board, see if it works. If not, check if you have the screen wired correctly like the picture above.
Did it work? If you got it to work, then play around with the text size, color, cursor positions, and actual text you want to type. You can add more lines by putting more display.println(" ") rows. Email Mr. Dorsey a picture if you make something really cool. |
Comments for what each line of code does.
the println direction means "print line". It is a lower case L, for ln meaning line. Not In for inside.
Get it to say what you want!
Play around with the text size, cursor location, and the text, or add new lines to get it to say different things. It's pretty fun, try it out!
Day 4's Lesson: Adding custom parts to code
Once you get code to work for one part, it is usually easy to add it into another code that also works.
Today your teacher will show you how to copy and paste code to manipulate code to work with additional Arduino parts. Teach them how to use the code library and website to self build what they want and add it to their robot.
Link to https://www.arduino.cc/en/Tutorial/BuiltInExamples
(differentiation day: student that are behind get time with teachers to troubleshoot. Students that are ahead get to look through the supplemental lessons or book manual and learn how to do more at own pace.
Today your teacher will show you how to copy and paste code to manipulate code to work with additional Arduino parts. Teach them how to use the code library and website to self build what they want and add it to their robot.
Link to https://www.arduino.cc/en/Tutorial/BuiltInExamples
(differentiation day: student that are behind get time with teachers to troubleshoot. Students that are ahead get to look through the supplemental lessons or book manual and learn how to do more at own pace.
Displaying Pictures to the OLED
Before we can put an image on the screen, we have to turn a picture you want into a format that this screen and Arduino knows how to use (128 by 64 pixel OLED Screen).. Here is a tutorial for how to do that. Here is a link to a useful online tutorial.
https://learn.adafruit.com/adafruit-gfx-graphics-library/graphics-primitives
https://learn.adafruit.com/adafruit-gfx-graphics-library/graphics-primitives
Test: Displaying The OLED Manufacturer's Logo
The most basic thing we need to do first is getting the code to initialize the display. The code to the right comes directly from the manufacturer and is the minimum needed to get the display ready to start working.
If all you do is get the board started and nothing else, the logo stays up forever. Type up this code and wire the LED like the last LED lesson. Upload it to the board and make sure it works. It looks similar to this picture, but your colors may be different based on the screen colors. |
Students, fill out this form for a post survey |
Show and Tell
At 12:00 parents are invited to our classroom (158 and 159) for a short show-and-tell where students can share the things they designed on the computer and built. Mr. Dorsey will share other regional STEM opportunities your family can consider when your students get older.
It's time to prep for the show!
Check that all your electronics and code work for what you want to share for the ending presentation and set up anything else you were able to make. Finalize what you want to show your teachers, the other students, and parents.
Your spaces should be cleaned and ready to present by 11:45.
Your spaces should be cleaned and ready to present by 11:45.
Go Beyond
Below is the manual for an Arduino kit similar to the one you have in this camp.
Here are some of the built in examples Arduino's program comes with:
https://www.arduino.cc/en/Tutorial/BuiltInExamples
If you are interested in adding other parts to your arm that we have not taught you, then feel free to look up how. Here is a tutorial book if you are interested.
Here are some of the built in examples Arduino's program comes with:
https://www.arduino.cc/en/Tutorial/BuiltInExamples
If you are interested in adding other parts to your arm that we have not taught you, then feel free to look up how. Here is a tutorial book if you are interested.
Your browser does not support viewing this document. Click here to download the document.
Other STEM Student Opportunities
Want to continue in STEM? See the following opportunities!
All of these programs are FREE!
All of these programs are FREE!
Here are some other regional opportunities you might want to consider in the coming years.
Summer Residential Governor's School
Rising 11th and 12th graders:
Highly regarded summer experiences for public school students.
See this link for more info:
https://www.doe.virginia.gov/teaching-learning-assessment/specialized-instruction/governor-s-schools/summer-residential-governor-s-schools
Below is this summer's info.
Note, students applying this Fall are for the Summer of 2024.
Academic Programs
Highly regarded summer experiences for public school students.
See this link for more info:
https://www.doe.virginia.gov/teaching-learning-assessment/specialized-instruction/governor-s-schools/summer-residential-governor-s-schools
Below is this summer's info.
Note, students applying this Fall are for the Summer of 2024.
Academic Programs
- Agriculture
- Humanities
- Mathematics, Science & Technology
- Engineering (Jefferson Lab)
- Marine Science (VA Institute of Marine Science)
- Dance
- Instrumental Music
- Vocal Music
- Theatre
- Visual Arts
Area Health Education Center (AHEC)
Summer STEM-Health Camp (That is this camp, YAY!)
Workshops
AHEC Scholars Program (eligibility: two-year health program or longer—example ADN)
Summer Enrichment Experience stem camp is designed to promote science and
medicine to rising sophomores, juniors, and seniors from local high schools. Campers
are introduced to human anatomy and physiology as well as a variety of healthcare
professions through modules and learning workshops. Each camper will receive a box of
learning tools to help provide an interactive experience.
Workshops
AHEC Scholars Program (eligibility: two-year health program or longer—example ADN)
Summer Enrichment Experience stem camp is designed to promote science and
medicine to rising sophomores, juniors, and seniors from local high schools. Campers
are introduced to human anatomy and physiology as well as a variety of healthcare
professions through modules and learning workshops. Each camper will receive a box of
learning tools to help provide an interactive experience.
Area Health Education Center Student Registry
Area Health Education Center (AHEC) has a state-wide student registry to inform students of events, programs, and services that will be pertinent to healthcare educational and career development.
Are you interested in a career in healthcare? Relevant fields include nursing, dentistry, doctor, physical therapist, etc. If so, you should sign up for the state's student registry. It will keep you informed about career opportunities, education options, and potentially scholarships. Use the link below to join the group. Our region is called the Rappahannock region.
https://www.vhwda.org/health-workforce/student-registry
Are you interested in a career in healthcare? Relevant fields include nursing, dentistry, doctor, physical therapist, etc. If so, you should sign up for the state's student registry. It will keep you informed about career opportunities, education options, and potentially scholarships. Use the link below to join the group. Our region is called the Rappahannock region.
https://www.vhwda.org/health-workforce/student-registry
Chesapeake Bay Governor's School (CBGS)
The Chesapeake Bay Governor's School for Marine and Environmental Science is your region's STEM magnet school open to area public school students from 10th to 12th grade. Students apply while in 9th grade.
If you are interested, it is worth talking to guidance now to discuss your student's math track. Students should need to have geometry finished before enrolling in CBGS, but having Algebra II done before enrolling usually leads to students performing better.
If you are interested, it is worth talking to guidance now to discuss your student's math track. Students should need to have geometry finished before enrolling in CBGS, but having Algebra II done before enrolling usually leads to students performing better.
RCC Dual Enrollment (DE)
RCC DE Webpage: rappahannock.edu/academics/dual-enrollment/
Dual enrollment programs enable students to take community college courses while enrolled in high school and provides college level opportunities not otherwise available. Dual enrollment allows qualified high school juniors and seniors to enroll in college courses during the school day where they receive both college and high school credit prior to high school graduation. Freshmen and sophomores can enroll with special approval from RCC’s administration.
Dual Enrollment has the opportunity to provide you with enough credits to graduate from high school with your Associate's Degree from RCC . You graduate from both high school and college your senior year! Please use the link above to learn more. It is never to early to plan! Inquiries can go to Mr. Dorsey or Hutt Williams.
Dual enrollment programs enable students to take community college courses while enrolled in high school and provides college level opportunities not otherwise available. Dual enrollment allows qualified high school juniors and seniors to enroll in college courses during the school day where they receive both college and high school credit prior to high school graduation. Freshmen and sophomores can enroll with special approval from RCC’s administration.
Dual Enrollment has the opportunity to provide you with enough credits to graduate from high school with your Associate's Degree from RCC . You graduate from both high school and college your senior year! Please use the link above to learn more. It is never to early to plan! Inquiries can go to Mr. Dorsey or Hutt Williams.
Virginia Space Grant
VSGC Website: https://vsgc.odu.edu/
8th - 9th grade: Building Leaders for Advancing Science and Technology (BLAST) https://vsgc.odu.edu/blast/ 10th grade: Virginia Space Coast Scholars (VSCS) https://vsgc.odu.edu/spacecoast/ 11th or 12th grade: The Virginia Earth System Science Scholars (VESSS) https://vsgc.odu.edu/vesss/ 11th or 12th grade: Virginia Aerospace Science and Technology Scholars (VASTS) https://vsgc.odu.edu/vasts/ 16 years or older: Pathways Flight Academy https://vsgc.odu.edu/pathwaysflightacademies/ College: NASA Internships: https://intern.nasa.gov/ STEM Scholarships: https://vsgc.odu.edu/scholarships-fellowships/ https://vsgc.odu.edu/communitycollegescholarships/https://vsgc.odu.edu/stembridge/ Community College Internships/Stem Takes Flight: https://vsgc.odu.edu/stemtakesflight/ |
Community College for Health Care!
Rappahannock Community College is known throughout the area for having the very best instruction in the field of Health Sciences (for credit and non-credit.) Many graduates from our degree, certificate, and career study certificate programs go on to begin a career in the field that they’ve studied here, and many have continued their education at four-year degree schools as well.
Check out what is available through RCC:
Nursing:
Pre-BSN Specialization (Associate's Applied Science Transfer Degree)
ADN Nursing (Associate's Applied Science Degree)
Nurse Aide
Pre-Nursing
Practical Nursing (Certificate)
Pre-Practical Nursing
Emergency:
EMS - Paramedic I
EMS - Paramedic II
EMT – Advanced
EMT – Emergency Medical Technician
Pre-Paramedic
Other Medical:
Phlebotomy
Pre-Medical Lab Tech
Medical Laboratory Technology
Respiratory Therapy (Assoc. Applied Science Degree)
Psychology/Social Work (AA&S Transfer Degree)
Health STEM (AA&S Transfer Degree)
Workforce Offerings:
Nurse Aide Certification Training
Medication Aide
Sonography Technician
Pharmacy Technician
Basic Life Support and CPR for Healthcare Professionals
Check out what is available through RCC:
Nursing:
Pre-BSN Specialization (Associate's Applied Science Transfer Degree)
ADN Nursing (Associate's Applied Science Degree)
Nurse Aide
Pre-Nursing
Practical Nursing (Certificate)
Pre-Practical Nursing
Emergency:
EMS - Paramedic I
EMS - Paramedic II
EMT – Advanced
EMT – Emergency Medical Technician
Pre-Paramedic
Other Medical:
Phlebotomy
Pre-Medical Lab Tech
Medical Laboratory Technology
Respiratory Therapy (Assoc. Applied Science Degree)
Psychology/Social Work (AA&S Transfer Degree)
Health STEM (AA&S Transfer Degree)
Workforce Offerings:
Nurse Aide Certification Training
Medication Aide
Sonography Technician
Pharmacy Technician
Basic Life Support and CPR for Healthcare Professionals