Arduino…
So a colleague of mine gave a course on how to program an Arduino boards. For this course, a bunch of starter kits with an Arduino Duemilanove were ordered. The kit included a board equipped with a ATMEGA328 processor, a breadboard and set of cables and LEDs. With this new toy, I spent a few hours building stuff. My last experience with micro-controller programming was at the university, and I must say that today’s kit a way easier to use. Back-then we had to program the EEPROM in assembly, load them with the code after having erased them with ultra-violet light. The Arduino board has a USB port and a chip that emulates a serial port, this means the program can be loaded directly from the IDE into the flash memory and the one can communicate with the program by the way of the serial port. It took a quarter of an hour to test some code, now only a few seconds are needed.
The board includes various input/ouputs, but also an onboard LED that can be controlled, so it is perfectly possible to work just with a laptop, a USB cable and the board. So I was able to do keep coding while riding the train between Zürich and Geneva. I took the opportunity to write a small program that translates the text send to the serial port into morse code. He is the result:
const int ledPin = 13;
const int shortDelay = 200;
const int longDelay = shortDelay * 3;
const int spaceDely = longDelay * 2;
const char* charTable[] = {
".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..", ".---", "-.-", // K
".-..", "--", "-.", "---", ".--.", "--.-", "-.-", "...", "-", "..-", "...-", ".--",
"-..-", "-.--", "--..",
};
const char* numberTable[] = {
"-----", ".----", "..---", "...--", "....-", ".....",
"-....", "--...", "---..", "----.", "-----",
};
void ditChar(char c) {
if (c == '.') {
digitalWrite(ledPin, HIGH);
delay(shortDelay);
}
if (c == '-') {
digitalWrite(ledPin, HIGH);
delay(longDelay);
}
if (c == ' ') {
delay(longDelay);
}
digitalWrite(ledPin, LOW);
delay(shortDelay);
}
void ditString(const char* string) {
while(*string) {
ditChar(*string++);
}
delay(longDelay);
}
void morse(char c) {
if (c >= 'A' && c< = 'Z') {
ditString(charTable[c - 'A']);
} else if (c >= 'a' && c < = 'z') {
ditString(charTable[c - 'a']);
} else if (c >= '0' && c < = '9') {
ditString(numberTable[c - '0']);
} else {
ditChar(c);
}
}
void setup() {
Serial.begin(9600);
}
void loop() {
char c = Serial.read();
if (c >= 0) {
morse(c);
Serial.write(c);
}
}


Ok, but concretely, what do you plan to use it for?
I don’t have clear plan, I’ll probably build some advanced blinken-light…
Geek Christmas lights!
see more Epic Fails
Oops: I meant to link to this image.