Intro to Arduino UNO with an SOS Blink #tt19
Tinkerer: Lory Livezey
In this tutorial we're going to program the onboard LED to blink out an SOS signal. This should get your feet wet with the simplest of Arduino projects!
In this tutorial we're going to program the onboard LED to blink out an SOS signal. This should get your feet wet with the simplest of Arduino projects!
Previous Step
<<Installing Arduino for Windows<<
What you will need
- !!Keyestudios Arduino UNO R3 (or other compatible)!!
- !!USB Cable, A to B, 3 Feet!!
- Windows PC or Mac
Open Arduino Software
If you haven't installed it, refer to Installing Arduino for Windows.
Open the Blink Sketch
Now, the software is all set to write programs to the board. Next, we're going to open "Blink", a sample "sketch" (program) that the Arduino comes loaded with. You can tell that the sketch is working when you turn on the UNO and see a light blinking once per second, like this:
Let's open the Blink sketch that the Arduino comes loaded with.
File > Examples > 01.Basics > Blink
Ensure the Arduino/Genuino UNO board is selected:
Tools > Board > Arduino/Genuino UNO
Ensure the port where the UNO is plugged in is selected:
Tools > Port > COMXXX
The Arduino has two main functions. The Setup() function runs once when it starts up. LED_BUILTIN is a name (constant) that refers to the LED light on the board. The line below sets the LED to "OUTPUT" so that we can write values to it.
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}
The second function is a Loop() function. The loop will continue for as long as the board is on, constantly checking to see if something interesting has happened, or to run something over and over. In our case, below, the light is turned on (HIGH), there is a 1000 millisecond (1 second) delay, then it's turned off (LOW) for another second. Because it's looping, it will continue to do this forever.
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
Modify the Blink Sketch to Send an SOS
In this example, we're going to have the LED flash an "SOS" in Morse Code. Morse Code is how people used to communicate before all the fancy technology. It consists of short signals (dots) and longer signals (dashes). SOS is "...---...". We'll make a "dot" 100ms and a "dash" 500ms. This is the amount of delay we put in between each line where we change from HIGH to LOW voltage.
// the loop function runs over and over again forever
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for 100 ms
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(100);
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for 100 ms
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(100);
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for 100 ms
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(100);
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(500); // wait for 500 ms
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(100);
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(500); // wait for 500 ms
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(100);
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(500); // wait for 500 ms
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(100);
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for 100 ms
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(100);
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for 100 ms
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(100);
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for 100 ms
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(1000);
}
I'm sure our SOS isn't going to get anyone's attention, but it should give you a basic understanding of how to upload a simple program to the Arduino, that sends a series of commands to the onboard LED.