Summer Programming Camp

Subtitle: Programming Robotics Control Systems and Sensors


The objective is to teach basic programming, electronics and robotics concepts.  The students would have had no previous exposure to programming.  Those who continue to be interested can move on to learning Java.  A 'Merit badge' can be awarded on completion.

There will be about 5 hands-on projects.  The session will last 2 months, with weekly meetings.  Each meeting can be about 3 hours long.  There will be a moderated email forum for questions and for requesting help.  Additional Internet based meetings may be scheduled if needed. 

No more than 7 students.  Perhaps 5?

The course requires that students do a lot of work at home by themselves.   They will be encouraged to help each other when they encounter problems.  Meetings will be mostly for showing off progress and for introducing new concepts.  Students will be provided with parts that they can take home.  Each students must have a functioning computer, preferably a laptop (Win or Apple). 

Each students will work on projects of increasing complexity.  The final project will be a small robot that can move autonomously and be controlled remotely using a phone or tablet.


Robotics involves several disciplines.  A partial list follows:


This course focuses on Software Programming and Control Systems, and starts to provide the students with a basic knowledge of other aspects of robotics. 

Programming takes a long time to learn.  Each individual has to learn it their own way, typically by making many mistakes.  It is not a group activity; members in a group will tend to distract each other.  Most of the actual learning must be done while the student is working alone, typically at home.  Therefore, each student will need to take a kit of parts home.  An inexpensive kit will be provided.  The goal of this course is to make learning programming fun (rewarding) and easy (less frustrating).


An inexpensive kit will be provided to each student.  Parts will be purchased in bulk from eBay (enough for 10 kits) and then distributed into kits.  Note that parts delivery can be slow, typically 6 weeks.

Students can take away the completed projects for personal use.  Students must provide their own laptop and AA batteries.


Microcontroller (Arduino clone)


USB - Serial programming interface




Power supply/regulator


Motor controller


Ultrasonic distance sensor


Optical sensors, LEDs , Resistors & Capacitors


Proto bread board


Jumper wires


Geared motors + wheels = car


Approx total per kit



1.       Set up Arduino IDE environment on laptop

2.       Blinking light program

a.       Wiring 101

b.      Modify Blinking lights to Fading light

3.       Light sensor program

a.       Modify light sensor to blink synchronized with blinking lights program

4.       Windmill / pin wheel program

a.       Modify to Variable speed

b.      Modify to Light sensing pin wheel

5.       2 wheel drag tail robot

a.       Modify to Robot moving in circle

b.      Randomly moving robot (Roomba)

c.       Modify to Robot dancing to music

6.       Light following robot (Sidewinder)

a.       Modify to Line following robot

                                                               i.      Follow path marked with black tape

b.      Modify to Obstacle / Collision avoiding robot

c.       Robot racing event

7.       Optional Keystone project: Remote control robot (may require additional parts)

Lesson Details

  1. Lesson 1: Setup
    1. Hand out the hardware kit and go over the components.
    2. Set up wiring for Blink program.  Explain:

                                                               i.      DC power

                                                             ii.      Resistors, Diodes, Caps

                                                            iii.      Diode polarity

                                                           iv.      IO ports

    1. There is a write up on how to install and configure the IDE on a PC.  Students will be shown how to install IDE on their laptops.
    2. Explain concepts for Blink program below

int led = 13;

// the setup routine runs once when you press reset:

void setup() {              

                pinMode(led, OUTPUT);    



// the loop routine runs over and over again forever:

void loop() {

                digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)

                delay(1000);                       // wait for a second

                digitalWrite(led, LOW); // turn the LED off by making the voltage LOW

                delay(1000);                       // wait for a second



                                                               i.      Program Flow: setup(), loop()

                                                             ii.      Program style: indents, spacing, comments

                                                            iii.      variables

                                                           iv.      functions

                                                             v.      IO ports

                                                           vi.      Googling for answers; Ask Google first

    1. Arduino IDE

                                                               i.      Edit

                                                             ii.      Run

                                                            iii.      How to Debug

                                                           iv.      Print statements

    1. Modify: Vary the delay: fast blink, slower blink
    2. Modify: Double blink: Duplicate digitalWrite() & delay() inside the loop
    3. Modify: Triple blink: Introduce for loop concept
    4. Discussion on Electronics

                                                               i.      Ohm's law, etc.

                                                             ii.      LED wiring

                                                            iii.      Calculating current through a diode

                                                           iv.      Digital High vs. Low

                                                             v.      Serial vs. parallel I/O

  1. LED Fade in fade out
    1. Explain concepts for following pgm

int ledPin = 9;                     // LED connected to digital pin 9

void setup()  {                     // nothing happens in setup



void loop()  {                        // fade in from min to max in increments of 5 points

                for (int fadeValue = 0 ; fadeValue < 250; fadeValue +=50) {

                                analogWrite(ledPin, fadeValue);        

                                delay(300); // wait 300 ms to see the dimming effect   



                for (int fadeValue = 255 ; fadeValue > 5; fadeValue -=50) {

                                analogWrite(ledPin, fadeValue);        

                                delay(300);          // wait to see the dimming effect   




                                                               i.      Re-discuss for loop, loop values

                                                             ii.      Analog pin, vs. digital in previous project

                                                            iii.      Brightness range: 0 - 255

                                                           iv.      Determine fade-in fade-out times (5x300 ms)

                                                             v.      Discuss PWM

                                                           vi.      Modify: Make the fade smoother (reduce delay)

                                                          vii.      Modify: Make fade longer: 5 in, 5 out

    1. Modify: Wire a motor controller for PINWHEEL project

                                                               i.      Run motor without load

                                                             ii.      Modify: Add a pinwheel as load

  1. Light Sensor
    1. Wire up a Light sensor to Analog port
    2. Explain concepts

int sensorPin = 1;             // sensor connected to digital pin 1

void setup()  {



void loop() {

                int value = analogRead(sensorPin);

                value /= 5;                           // scale [0-51]

                for (int i = 0; i < value; ++i)            // display bar graph


                Serial.println(value);       // value \n



    1. Shine light on sensor, vary intensity
    2. Modify: Count flashes and print value

boolean wasBright = false;

int flashes = 0;

void loop() {

                int value = analogRead(sensorPin);

                boolean isBright = (value > 100);

                if (isBright  &&  ! wasBright)         // changed


                wasBright = isBright;


                                                               i.      booleans

                                                             ii.      the auto-increment operator

                                                            iii.      Simulate going through the loop

    1. Explain concepts

                                                               i.      Interrupts & interrupt processing

                                                             ii.      Explain counting "Rising edge" / "Falling Edge"

    1. Modify: Count flashes per second and print value

                                                               i.      print flashes once a sec and reset

if ((millis() % 1000) == 0) {


                flashes = 0;


                                                             ii.      What is wrong with above code?  May miss the 0.

millisNow = millis();

if (millisNow < millisPrevious) {


                flashes = 0;


millisPrevious = millisNow;

    1. Modify: Make an Encoder: Use counts to measure Pinwheel speed on Instructor's wheel. Print RPM & FPS.   Encoder can have slots or dots painted on wheel and illuminated by an LED through a straw.

int rpm = (flashes * 60.0) / NUM_SPOKES

int fps = ((float) flashes / NUM_SPOKES) * PI * WHEEL_DIA / 12;

                                                               i.      Introduce floating point, cast and expression evaluation (/ 12 is float divide)

                                                             ii.      Vary Pinwheel speed and see it tracked by encoder

  1. Attach Control system to Robot vehicle
    Wiring diagram for the motors.  Use the Drive sketch.  An Android app for driving the robot is available at  Other platforms can use a browser interface.



    1. moveForward() for 2 seconds and moveBack() 2 secs
    2. moveForward() 2 feet and moveBack() 2 feet
    3. Turn (angle)                                       angle can be +/- 30 degrees
    4. spinAround(angle)         
    5. moveInCircle(radius)                      radius can be 3 feet
    6. moveRandomly(t)                           Roomba Rumba.  Randomly pick a motion from above and perform for t ms.
    7. danceToMusic(wavFile)                play music using speaker, move to music
    8. Explain concepts

                                                               i.      Motor controllers

  1. Light following Robot

Wiring for the Wheel Encoder Sensors.  Note that the two LEDs are wired in series to save on current usage.  Also the output has a voltage divider to reduce max voltage to 3.3 Vdc.  The 4.7k resistor can be deleted if you are using a 3.3 Vdc supply.  Note that the Wheel Encoder spokes interrupt the IR beam between the LED and corresponding sensor.

    1. Use light sensors to follow bright light
    2. Modify: reposition sensors to illuminate and follow a black 0.5" tape on floor.
    3. Modify: Find and intercept tape, then follow it
    4. Modify: Reverse when tape runs out, repeat.
  1. Collision avoidance using Ultrasonic range finder
    1. Stop and honk at obstacle (or say "Excuse me")
    2. Find a way around the obstacle and resume tracking line
  2. Remote control using WiFi.
    1. Use a simple Android app to control the robot.  Use voice guidance. 
    2. Drive the robot over the Internet from across the world :-)