Description
This lab consisted of three steps: install the arduino environment on my computer, set up an LED on the breadboard, and change the blink example sketch to have the LED blink at my own rate. The LED is grounded with the green wire, and connected to a 220 ohm resistor, which leads to the arduino through the orange wire.
After trying a few different blink speeds, I decided to get the LED to blink my name (Alexis) in Morse code because I didn't want it to simply blink, I wanted it to communicate something. I programmed the arduino according to the International Morse code standard, which specifies one unit of length for dots, three for dashes, one for spaces between dots and dashes within a letter, three between letters, and seven between words. It basically consisted of a lot of copying and pasting the example code to be long enough. I commented out the code so you can see which parts represent which letters.
Components Used
1 arduino uno R3 (5V)
1 220 Ω resistor
1 LED
3 wires (2 green, 1 orange)
1 USB cable
Code
int led = 13;
void setup() {
pinMode(led, OUTPUT);
}
void loop() {
/*
A (dot-dash)
*/
digitalWrite(led, HIGH);
delay(100); // dots are 1 unit long
digitalWrite(led, LOW);
delay(100); // intra-letter spaces are 1 unit long
digitalWrite(led, HIGH);
delay(300); // dashes are 3 units long
digitalWrite(led, LOW);
delay(300); // end of letter spaces are 3 units long
/*
L (dot-dash-dash-dash)
*/
digitalWrite(led, HIGH);
delay(100);
digitalWrite(led, LOW);
delay(100);
digitalWrite(led, HIGH);
delay(300);
digitalWrite(led, LOW);
delay(100);
digitalWrite(led, HIGH);
delay(300);
digitalWrite(led, LOW);
delay(100);
digitalWrite(led, HIGH);
delay(300);
digitalWrite(led, LOW);
delay(300);
/*
E (dot)
*/
digitalWrite(led, HIGH);
delay(100);
digitalWrite(led, LOW);
delay(300);
/*
X (dash-dot-dot-dash)
*/
digitalWrite(led, HIGH);
delay(300);
digitalWrite(led, LOW);
delay(100);
digitalWrite(led, HIGH);
delay(100);
digitalWrite(led, LOW);
delay(100);
digitalWrite(led, HIGH);
delay(100);
digitalWrite(led, LOW);
delay(100);
digitalWrite(led, HIGH);
delay(300);
digitalWrite(led, LOW);
delay(300);
/*
I (dot-dot)
*/
digitalWrite(led, HIGH);
delay(100);
digitalWrite(led, LOW);
delay(100);
digitalWrite(led, HIGH);
delay(100);
digitalWrite(led, LOW);
delay(300);
/*
S (dot-dot-dot)
*/
digitalWrite(led, HIGH);
delay(100);
digitalWrite(led, LOW);
delay(100);
digitalWrite(led, HIGH);
delay(100);
digitalWrite(led, LOW);
delay(100);
digitalWrite(led, HIGH);
delay(100);
digitalWrite(led, LOW);
delay(700); // end of word spaces are 7 units long
}