Landing : Athabascau University
  • Blogs
  • Circuit 1A: Blink an LED

Circuit 1A: Blink an LED

This circuit was simple and I had no issues building it. Instead of using the blink example code, I used the morse code program that I wrote for assignment 0. The morse code program makes the LED blink my name (Adam) in morse code. The program looks like this:

# define LED_PIN 13 // Pin number attached to LED.
void setup() {
// put your setup code here, to run once:
pinMode(LED_PIN, OUTPUT); // Configure pin 13 to be a digital output.
}
void loop() {
// put your main code here, to run repeatedly:
letterA();
longSpace();
letterD();
longSpace();
letterA();
longSpace();
letterM();
longerSpace();
}
void letterA(){
dit();
space();
dah();
}
void letterD(){
dah();
space();
dit();
space();
dit();
}
void letterM(){
dah();
space();
dah();
}
void dit(){
digitalWrite(LED_PIN, HIGH); // Turn on the LED.
delay(100); // Wait 0.1 seconds (100 milliseconds).
}
void dah(){
digitalWrite(LED_PIN, HIGH); // Turn on the LED.
delay(300); // Wait 0.3 seconds (300 milliseconds).
}
void space(){
digitalWrite(LED_PIN, LOW); // Turn off the LED.
delay(100); // Wait 0.1 seconds.
}
void longSpace(){
digitalWrite(LED_PIN, LOW); // Turn off the LED.
delay(300); // Wait 0.3 seconds.
}
void longerSpace(){
digitalWrite(LED_PIN, LOW); // Turn off the LED.
delay(700); // Wait 0.7 seconds.
}

Here is a video of the program in action on Circuit 1A:  MorseCodeAdam

 

Comments

These comments are moderated. Your comment will not be visible unless accepted by the content owner.

Only simple HTML formatting is allowed and any hyperlinks will be stripped away. If you need to include a URL then please simply type it so that users can copy and paste it if needed.

(Required)

(Required)