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.
$3.50 |
|
$2 |
|
$0.30 |
Adapter |
$1 |
Power supply/regulator |
$2.50 |
Motor controller |
$2 |
Ultrasonic distance sensor |
$1 |
Optical sensors, LEDs , Resistors & Capacitors |
$2.70 |
Proto bread board |
$1 |
Jumper wires |
$12 |
Geared motors + wheels = car |
~$35 |
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)
i. DC power
ii. Resistors, Diodes, Caps
iii. Diode polarity
iv. IO ports
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
}
Concepts:
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
i. Edit
ii. Run
iii. How to Debug
iv. Print statements
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
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
}
}
Concepts:
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
i. Run motor without load
ii. Modify: Add a pinwheel as load
int sensorPin = 1; // sensor connected to digital pin 1
void setup() {
Serial.begin(9600);
}
void loop() {
int value = analogRead(sensorPin);
value /= 5; // scale [0-51]
for (int i = 0; i < value; ++i) // display bar graph
Serial.print('-');
Serial.println(value); // value \n
delay(50);
}
boolean wasBright = false;
int flashes = 0;
void loop() {
int value = analogRead(sensorPin);
boolean isBright = (value > 100);
if (isBright && ! wasBright) // changed
Serial.println(++flashes);
wasBright = isBright;
}
i. booleans
ii. the auto-increment operator
iii. Simulate going through the loop
i. Interrupts & interrupt processing
ii. Explain counting "Rising edge" / "Falling Edge"
i. print flashes once a sec and reset
if ((millis() % 1000) == 0) {
Serial.println(flashes);
flashes = 0;
}
ii. What is wrong with above code? May miss the 0.
millisNow = millis();
if (millisNow < millisPrevious) {
Serial.println(flashes);
flashes = 0;
}
millisPrevious = millisNow;
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
i. Motor controllers
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.