If you've gotten this far you probably want some details about using a micro controller/ For this piece, the prototyping was done on an ARduino Duemilenove, the second largest and easiest Arduino to work with since connections to it are sockets you can plug wires into rather than having to solder them ON to. an Arduino MiniPro - the smallest of the Arduino micro controllers available at this time.
So lets start with the parts and how they're wired together. The following diagram was done in a free software package called FRITZ. FRITZ makes creating What Connects To What a Drag and Drop process - that's quick and easy to learn - and use. That's in keeping with the whole Arduino Approach To Things - Learn By DOING rather than learn abstract concepts first, then apply them to something real. Start with playing with stuff - then - if you want, delve as deeply as you care to into the underlying theories / concepts.
So here's the FRITZ diagram of this piece's "hardware" - I'll get to the "software" in a minute.
We've got
- a battery
- an Arduino MiniPro programmable micro controller / micro computer
and
- a small servo with an arm the servo can swing aboutWe've also got six "pins" (Grn,Ylw, Orng,Red,Brn and Blk) that are used to connect the micro controller to your computer todownload software to the micro controller - sort of a phone line you can use to give the micro controller instructions on what you want it to do - once you've hung up. You can get the USB/TTL cable from most places that sell Arduino micro controllers. One end plugs into your computer's USB port and the other into the Arduino MiniPro. Larger versions of Arduinos have a normal sized USB connector or a mini USB connector on their boards.
HERE'S SOME IMPORTANT PIECES OF INFORMATION ABOUT THE ARDUINO YOU NEED TO BE AWARE OF
A USB connection from your computer to the Arduino has a maximum current capacity of about 50 milli amps.
If you try and draw more than 50 milli amps - you may FRY YOUR COMPUTER!
If you come ofF a USB Hub, that's connected to your computer,
each USB port on the Hub has a maximum current capacity of about 20 milli amps. Draw more and you can fry your USB Hub.The analog and digital pins on Arduinos each have a current capacity of only 40 milli amps, 20 milli amps recomended
The Arduino has an output total output current capacity of about 50 milli amps - total.
So if you use servos or motors they need to get their main power from another source (battery or transformer) and the Arduino only providing "control line" powerThe battery provides power (voltage and current - think water pressure and water flow) to the micro controller via two wires - Red is PLUS (+) and Black in Minus (-). These wires from the battery get connected (in this case soldered) to the RAW and GND (GrouND) points on the micro controller's PCB (Printed Circuit Board. The micro controller uses the battery provided power and passes some of that power to the servo - via a Red (+) wire and a Black (-) wire. The servo's third wire - the Orange wire is used to move the servo's arm - which way to move, how far to move and how long to stay there. The which way, how far and how long information comes from the micro controller that, in this case, uses Pin 9 on its PCB to send instructions to the servo.
Da SOFTWARE
And here's the Arduino "Sketch" (it's actually a computer program, but Sketchin sounds easier than PROGRAMING) - all eight lines of it.
(And you thought you'd be typing a page or two of instructions for the micro controller to use. To use and available "sketch", you don't even have to type - just cut and paste. And if you want to change that program - you need only type in the changes)
#include <Servo.h>
Servo myservo;
int pos = 0;
int delay1 = 0;
void setup()
{myservo.attach(9);}
void loop()
{ pos=random(65,115); delay1=random(50, 500); myservo.write(pos);delay(delay1);}
The above version of the Sketch for moving an eyeball around like a Speed Freak's Eye doesn't make a whole lot of sense to YOU - as is - but it's all the computer languages "compiler" needs to create the instructions the micro controller can understand - and execute. Think of the "compiler" as your translator, translating your "C" computer language instrutions into something the micro controller can do something with.
Let's look at a "commented" version of the program which may make more sense to you.
Anything between " /* " and " */ " is a Comment, as is anything following "//". T1he compiler ignores comments" - they're here for YOU only - to help explain something.
/*SPEED FREAK EYE
This version of the software behaves like the eyes of
a Speed Freak - darting about quickly, unable to remain
focused on one thing for more than an instant
Derived from
Sweep
by BARRAGAN <http://barraganstudio.com>
*/
#include <Servo.h> //include the servo libary - a bunch of code for a host of servo instructions y9ou can use and don't have to develop yourself
Servo myservo; // create servo object to control a servo
int pos = 0; // variable to store the servo position
int delay1 = 0; // variable to store the delay between servo arm's movement info
void setup()
{
myservo.attach(9); // attaches pin 9 of the micro controller to the servo object - the servo's "control wire"
}
void loop()
{
pos=random(65,115); // ramdomly set the servo arm postion between 65 & 115 degrees. "90" is "straight ahead"
delay1=random(50, 500); // randomly set delay between servo movement between 50 and 500 milliseconds
myservo.write(pos); // tell servo to go to position specified by variable pos value
delay(delay1); // waits randomly between 50ms and 500 ms between servo movements
}If all this has piqued your curiosity - and you want to see other examples of incorporating micro controller "behavior" CLICK HERE
This Eye Ball Behavior idea is interesting - and I'm already working on a way to use two servos - and a universal joint - to permit the eye to move in any direction.
More to come?