The first program that I decided to try out in the Arduino IDE is the "Blink" program. I copied the code straight from the Arduino Wikipedia article. It compiled and ran on the RedBoard with no issues.
After that, I decided to try to edit the code to make the LED blink faster. This new, faster version of Blink also compiled and ran on the RedBoard with no issues.
Next, I decided to use what I learned from the Blink program to write a program to make the LED blink my name (Adam) in morse code. I took a quick look at the Morse code Wikipedia article and learned that morse code is a series of "dits", "dahs", and "spaces". There is also a chart in the Wikipedia article that shows each letter of the English alphabet and its corresponding representation in morse code. With this new knowledge of morse code coupled with the knowledge I gained from the Blink program, I was able to write a program in the Arduino IDE to make the LED blink my name in morse code. This program compiled and ran on the RedBoard with no issues.
The morse code 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.
}
Maybe in the future I will write a program that allows the RedBoard to produce morse code based on some input.
The Landing is a social site for Athabasca University staff, students and invited guests. It is a space where they can share, communicate and connect with anyone or everyone.
Unless you are logged in, you will only be able to see the fraction of posts on the site that have been made public. Right now you are not logged in.
If you have an Athabasca University login ID, use your standard username and password to access this site.
We welcome comments on public posts from members of the public. Please note, however, that all comments made on public posts must be moderated by their owners before they become visible on the site. The owner of the post (and no one else) has to do that.
If you want the full range of features and you have a login ID, log in using the links at the top of the page or at https://landing.athabascau.ca/login (logins are secure and encrypted)
Posts made here are the responsibility of their owners and may not reflect the views of Athabasca University.