The Proto Cylon
By Bobby Neal WintersI’ve been captured by another enthusiasm. The Arduino controller card. If you go to http://arduino.cc/en/, then you can learn as much as I know about it in short order. There is probably a fancy name for it, and if you read the whole page on the link I just gave you, then you can probably find it. Regardless of what you call it, it is basically a little computer that you can use to run stuff.
It costs about $20.
I learned of its existence while looking around for Raspberry Pi. This turns out to be a slightly different kettle of fish, but I will doubtless return to Raspberry Pi eventually. But I digress.
The Arduino collection of cards give you the ability to interact with the mechanical world. You can control a small amount of electrical current using the C programming language. This appealed to the same part of my brain that was attracted to the Potato Cannon and the Itty Bitty Ubuntu Box.
(Since it controls a small amount of current and the potato cannon needs a small amount of current to produce a spark, there is even the possibility of combining the two. Using an Arduino card to make a potato machine gun. Hmmmm.)
In any case, one of the classical projects for a card such as this is to make a robotic car. That is my long range goal. But why stop with just a car? Why not think really long range and work one’s way up to a Cylon. (I am thinking a Six or an Eight. The Threes aren’t stable.) In the meantime, we do baby steps. My first step is learning how to blink LEDs on breadboard. The code is below:
int inputPin=5;
int ledPin1=2;
int ledPin2=6;
int ledPin3=8;
void setup() {
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(ledPin3, OUTPUT);
pinMode(inputPin, INPUT);
digitalWrite(inputPin,HIGH);
}
void loop() {
blinkOff(ledPin1, 0);
blinkOff(ledPin2, 0);
blinkOff(ledPin3, 0);
blinkOn(ledPin1, 500);
blinkOn(ledPin2, 500);
blinkOn(ledPin3, 500);
blinkOff(ledPin3, 500);
blinkOff(ledPin1, 500);
blinkOff(ledPin2, 500);
}
void blinkOn( int ledNum, int duration)
{
int switchOpen=digitalRead(inputPin);
digitalWrite(ledNum, ! switchOpen);
delay(duration);
}
void blinkOff( int ledNum, int duration)
{
int switchOpen=digitalRead(inputPin);
digitalWrite(ledNum, switchOpen);
delay(duration);
}
This is what it looks like:
No comments:
Post a Comment