Arduino Coffeebots
Arduino Coffeebots
Michael Shiloh
Judy Castro
Contact: teachers@teachmetomake.com
This page can be reached at: bit.ly/coffeebot
Basic Robot
Robot with two light sensors and two motors:
/*
This program makes your robot either seek light or avoid light, depending on how it is wired up.
Try this program first, and then start modifying it to give your robot the personality you desire.
Shine a flashlight, or hold your hand over a light sensor, to change the behaviour.
*/
void setup()
{
// Set the mode of the digital pins to outputs to drive the motors
// (the analog inputs are automatically inputs and so don’t need to be set)
pinMode( 3, OUTPUT ); // motor
pinMode( 5, OUTPUT ); // motor
}
void loop()
{
// Compare the two light sensors
if ( analogRead( 0 ) > analogRead( 2 ) ) // If one light sensor has more light than the other ...
{
digitalWrite( 3, LOW ); // turn this motor off ...
digitalWrite( 5, HIGH ); // and this motor on to turn in one direction
}
if ( analogRead( 0 ) < analogRead( 2 ) ) // If the other
{
digitalWrite( 3, HIGH ); // turn this motor on
digitalWrite( 5, LOW ); // and this motor off to turn in the other direction
}
}
Add an LED
As an example of how to add things to your coffeebot, let’s attach an LED to pin 9.
Remember to use a resistor so that the LED doesn’t burn out:
And here is how we might use that LED in a program:
/*
This program makes your robot either seek light or avoid light, depending on how it is wired up.
Try this program first, and then start modifying it to give your robot the personality you desire.
Shine a flashlight, or hold your hand over a light sensor, to change the behaviour.
An LED is connected to pin 9; whenever the sensors measure unequal brightness this LED is turned on
*/
void setup()
{
// Set the mode of the digital pins to outputs to drive the motors
// (the analog inputs are automatically inputs and so don’t need to be set)
pinMode( 3, OUTPUT ); // motor
pinMode( 5, OUTPUT ); // motor
pinMode( 9, OUTPUT ); // LED
}
void loop()
{
// Compare the two light sensors
if ( analogRead( 0 ) > analogRead( 2 ) ) // If one light sensor has more light than the other ...
{
digitalWrite( 3, LOW ); // turn this motor off ...
digitalWrite( 5, HIGH ); // and this motor on to turn in one direction
digitalWrite( 9, LOW ); // turn off the LED
}
if ( analogRead( 0 ) < analogRead( 2 ) ) // If the other
{
digitalWrite( 3, HIGH ); // turn this motor on
digitalWrite( 5, LOW ); // and this motor off to turn in the other direction
digitalWrite( 9, LOW ); // turn off the LED
}
if ( analogRead( 0 ) == analogRead( 2 ) ) // If they read the same value
{
digitalWrite( 3, HIGH ); // turn this motor on
digitalWrite( 5, HIGH ); // and this motor too, to go straight
digitalWrite( 9, HIGH ); // turn on the LED
}
}
Links that might be useful or interesting:
- 123 robotics experiments for the evil genius is available for free via Google Books
- Really nice set of robot tutorials at Robotshop.
- I really like mailing lists, and there are plenty on the subjects of robots. Two of my favorites are the Dallas Personal Robotics Group and the Portland Area Robotics Society
Parts List
Robot Chassis Parts List
- Coffee can or other suitable container for body
- Craft sticks or other suitable materials for structural elements and decoration
- Wine corks or other suitable items for front and back caster mounts
- Water bottle caps or other suitable items for casters
- Zip ties for attaching Arduino to chassis
Robot Electronics Parts List
- N-chanel logic level MOSFET 12N10L
Jameco Part no. 1071214
quantity: 2 - Gear motor and wheel, Solarbotics GM8 with GMPW wheel deal
http://www.solarbotics.com/product/gmpw_deal/
quantity: 2
- LED (any type)
e.g. Jameco Part no. 2152112
quantity: 2 - Resistor for LED, 330 Ohm or so
Jameco Part no. 690742
quantity: 2 - Photoresistor
Jameco Part no. 120299
quantity: 2 - 150K Ohm Resistor for Photoresistor
Jameco Part no. 691382
quantity: 2 - Arduino Uno or Leonardo, or compatible
- Battery holder with switch and coax power connector
Maker Shed MSBAT1 - 9 Volt Battery
Class Consumables Parts List
- Wire (all the different colors
- Solder
- It is often cheaper to buy some parts such as LEDs, resistors, and photoresistors in bulk
Tools
Here are the basic tools that we find useful when constructing CoffeeBots:
1. A soldering iron. A fine tip is essential. Note the pencil size for comparison:
You can spend well over $100, but this particular model ($17 at Parts Express) is adequate.
2. Third hand:
This device has a pair of alligator clips on flexible arms. While not critical, it is extremely useful for holding things while you solder, for example holding the motor while you solder the wires to the motor terminals:
3. Hot melt glue gun:
4. Wire cutter, wire stripper, and needle nose pliers:
Most importantly, you want the wire cutters to have a small, fine tip, for cutting wires that are close to other wires:
That’s about it – it is useful to have other tools on hand but these are the only tools necessary










March 18, 2013 at 4:17 pm |
[...] is getting underway at the Bloomfield Science Museum. California artists and maker teacher team Teach Me to Make (Michael Shiloh and Judy Castro) traveled to Jerusalem as guests and Maker Faire emissaries and [...]
March 18, 2013 at 8:09 pm |
[...] is getting underway at the Bloomfield Science Museum. California artists and maker teacher team Teach Me to Make (Michael Shiloh and Judy Castro) traveled to Jerusalem as guests and Maker Faire emissaries and [...]
March 18, 2013 at 10:37 pm |
[...] of the things at the Maker Faire was CoffeeBots, small robots which use Arduino based electronics for easy modification and which were being [...]
March 18, 2013 at 10:41 pm |
[...] of the things at the Maker Faire was CoffeeBots, small robots which use Arduino based electronics for easy modification and which were being [...]