We've moved, all orders pick-up will now be at 550 Alden Road, Unit 104.
As a precaution to COVID-19, in-store purchase is NOT available but you may place your order online then pickup your order.
Shipping of online order is unaffected. Delivery may be delayed due to carrier backlog. Sorry for the inconvenience.

Project 1: Airplane Strobe Light

Posted by Rhiannon L on

Table of Contents


Introduction

Have you ever wondered how planes are able to see each other at night? In addition to their RADAR, they also use visual cues. One such visual cue is a strobe light. Strobe lights are blinking lights that every airplane has on the tips of its wings. They are the brightest lights on the plane. These lights are so powerful they can be seen from several kilometers away, providing ample warning to any nearby planes.

In this simple introductory project, you’ll learn to program an LED to blink on and off like the strobe light of an airplane. LEDs (light-emitting diodes) are small, powerful lights that can be found anywhere from inside your computer screen to the headlights of your car. In electronics, LEDs are often used to indicate that there is power in the circuit. This might not seem like much, but it will help you as we work toward more complex projects by providing a solid foundation of wiring and programming.

Although LEDs light up like a little light bulb, they are very different. LEDs have very little resistance and consume very little power. Their efficiency is why they are often used in place of other sources of light. This is also why the 330Ω resistor is necessary for this project: connecting the LED directly to the positive (+) and negative (-) terminals would create a short circuit, which could damage your Arduino.

Here is a circuit diagram graphically explaining how this project is going to work:

Circuit diagram

 Project 1 - Airplane Stobe Light

Parts List

This series of posts will guide you through your journey with Arduino with simple, easy-to-follow projects to help you get the basics down. Today’s post is about making a blinking LED to get the snowball rolling.

For this project  (Project 1 - Airplane Strobe Light), you’ll need these items:

 

For a full list of all the parts you'll need for this series of projects, visit our introductory blog, An Introduction to Arduino.

 

5V warning

5V Current. Your Arduino runs on five volts. 5V can’t hurt you, so don’t be afraid to touch anything in your circuit. This is the power that will be supplied from your computer via USB and will be the driving force behind any components you use in your circuits. By plugging your Arduino board into your computer, you are supplying it with just the right voltage it needs to thrive!

 

 

Three Steps to Any Arduino Project


Assemble the Circuit

If you’ve followed our series of posts, your Arduino and breadboard should already be set up. For help with this, refer to An Introduction to Arduino.

Before you assemble anything, unplug your Arduino from your computer, ensuring that there’s no power in the circuit. While the Arduino only uses 5V, which is far from enough to hurt you, if you accidentally plug wires into the wrong sockets, you could fry your Arduino.

Assemble the circuit using the diagrams below. Make sure to double check that all your wires and parts are plugged into the right terminals.

Wiring diagram 2

Wiring Diagram

 

If you recall from An Introduction to Arduino, pins 3, 5, 6, 9, 10, and 11 (all on the same side as the reset button) are digital pins. Digital pins, unlike analog, can only read two inputs: high and low. In the case of projects like this one, high means on and low means off. In other words, digital pins can only turn things on and off, which is all we need for a simple project like this one.

Note the red wire that connects the 5V output pin to the red positive rail of the breadboard. As you can probably guess, this provides 5V of power to the breadboard. It is common practice in the Arduino community to use red wires for power in.

Similarly, note the black wire that connects the GND (Ground) pin to the black negative rail of the breadboard. This grounds the circuit. Black wires are usually used to ground in Arduino.

Lastly, remember that the sockets in the breadboard connect in horizontal rows. This means that if you want to send power to the LED, you’ll have to connect the red positive rail to a particular row, and connect the LED in that same row. For example: sockets A1 and C1 connect, but not A1 and A4.

 

Write the Code

If you were to plug in the Arduino now, nothing would happen yet because it doesn’t know what to do. So let’s get to programming your Arduino.

In Arduino, programs are called sketches. To write sketches, Arduino uses the programming language C/C++ (pronounced “C-plus-plus"). In this post, we give short explanations of how the code used in this project works.

Here is what your code should look like. You can also play around with the code after to make it do different things. For example, you can try changing the delay time to make the LED blink faster or slower. There are also additional exercises for you to try at the end of this post.

Don’t worry about the colour of the words, the Arduino IDE will do this automatically for you.


void setup() {

  pinMode(11, OUTPUT);

}

void loop() {

  digitalWrite(11, HIGH);

  delay(1000);

  digitalWrite(11, LOW);

  delay(1000);

}

 

Explanation of the Code

Programming uses special programming languages so that the computer and Arduino can understand. Like any language, programming languages have their own grammar rules, called syntax. When programming, make sure to pay special attention to syntax. In real life, when you’re reading something written by someone else, you can still understand what they were trying to say if they made a grammar mistake. Unfortunately, computers are not the same, and they won’t work if your program has a syntax error. Syntax errors include using the wrong brackets (round ( ), curly { }, or square [ ]), misspelling words, forgetting a semicolon, etc.

void setup() - this function is pre-written in the Arduino IDE. It will only be executed once, at the beginning of the run.

void loop() - this function, like the setup function, is pre-written in the Arduino IDE. It will be executed and repeated indefinitely until the power runs out.

pinMode(11, OUTPUT) ; - tells the Arduino that you are using pin number 11 as an OUTPUT pin.

digitalWrite(11, HIGH) ; - sets pin number 11 to high (on). This only works because we’ve already told the Arduino that this is an output pin in pinMode(11, OUTPUT) ;

delay(1000) ; - tells the Arduino to do nothing (in other words, wait) for 1000 milliseconds (ms), aka 1 second.



Upload & Run

*Make sure the correct COM port (Tools > Port) is selected! For help with this, see An Introduction to Arduino.

When you’re finished copying the code above, press the following buttons:

Important Arduino commands


What You Should See

Once the upload is completed, “Done” will show up in the Arduino IDE message board. You should see your LED blink on and off in 1 second intervals. You can almost pretend you're staring out the window of an airplane and looking at the strobe light on the wing-tip, on your way to your dream vacation.

If the project isn't working, make sure you have assembled the circuit and written the code correctly. Also make sure you’ve clicked verify and upload. If it’s still not working like it’s supposed to, see the troubleshooting tips below.

 

Strobe Light Pattern

That's the basic code for making a blinking light! That being said, you may have noticed that actual airplane strobe lights don't blink at even intervals of one second on, one second off. In real life, airplanes actually have different blinking patterns depending on the type. An Airbus A320, for example, will blink twice in the first half of a second, then stay off for the second half.

If you want to try to challenge yourself and program this yourself, go right ahead. If not, you can try this code for an airplane strobe light pattern:

void setup() {

  pinMode(11, OUTPUT);

}

void loop() {

  for (int i = 0; i < 2; i++) {

    digitalWrite(11, HIGH);

    delay(50);

    digitalWrite(11, LOW);

    delay(50);

  }

  delay(800);

}

 

Troubleshooting

LED not lighting up?

First, check all the wiring. Is it correct? Then check the LED. LEDs only work in one direction. Try taking out the LED and turning it 180 degrees to switch the legs (don’t worry, installing it backwards won't do any permanent harm).

 

Program not uploading?

This happens sometimes. The most likely cause is a confused serial port. You can change this in Tools > Serial port > (usually COM3 or above). If it still won’t upload, try a different USB port or cable.


Still no success?

Remove everything from the breadboard and build the circuit again. If you are still having problems, send us an e-mail at support@carobot.ca and we will get back to you as soon as we can.


Exercises to Try

  1. Morse code is a way to communicate using ON-OFF sequences. The international help signal is “S.O.S.”. The sequence for “S” is three short pulses and the sequence for “O” is three long pulses. Modify the code to generate the “S.O.S.” sequence: • • • - - - • • • (Use 100 milliseconds (ms) for dots and 300 ms for dashes).
  2. Look up Morse code online and try to spell your name using the LED.

 

Did you enjoy this exercise? As you can see with the exercises at the end, even a simple project like this can be modified to perform important functions. Can you think of any other functions for a blinking light?


If you have any questions, leave a comment below. As this series progresses, more fun and interesting projects to guide you through the basics will be posted, so stay tuned!


Share this post



← Older Post Newer Post →


Leave a comment

Please note, comments must be approved before they are published.