LED Flash Challenge – Semester 2, 2019-2020

We’re beginning RoboSumo with a short competitive puzzle called the LED Flash Challenge. No formal assessment weight is attached to this challenge, but we’ll keep a close eye on who does well. In this challenge, doing well means two things: getting it working quickly and, more importantly, trying to understand what you’re doing.

In today’s lab you’ll be working with your team to complete two tasks:

  1. Build a simple breadboard circuit for the Arduino Nano and program it to blink alight-emitting diode (LED) on and off.
  2. Add a second LED to the circuit and reprogram the Arduino to transmit a specific binary sequence as a series of flashes from the two LEDs.

The first task is very prescriptive, which means that we’ll basically tell you exactly what to do, but to complete the second task you’ll need to think for yourselves.

You need a team number to complete this challenge. Your tutor will assign your team a unique number within the range shown below:

  • Teams 60-79: DT066A Groups A1 and A2 with Ted Burke and Gavin Duffy in room KEG-036 (located on a side corridor off the main ground floor corridor)
  • Teams 80-89: DT066A Group B1 with Emma Robinson in room KE4-018/KE4-023 (exact room TBC)
  • Teams 90-99: DT066A Group B2 with Mick McKeever in room KE4-018/KE4-023 (exact room TBC)

Part 1: Blinking LED

This task is relatively straightforward and shouldn’t take you too long to get working.

The “breadboard” is the rectangular white plastic board we use to build the circuit. Each short row of five holes is a single electrical connection. Two wires inserted into the same row become connected electrically. Each row is marked with a number and each column is marked with a letter, so that each hole in the main section of the board can be uniquely identified using a letter and number. The instructions below use these letters and numbers to identify the exact position of each component.

The breadboard comes with an adhesive strip on the back of it, which is covered by a protective sheet. Do not remove the protective sheet! Once the breadboard sticks to something it cannot be moved without compromising the internal structure of the breadboard.

Before beginning, make sure your breadboard is the same way around as the picture below.


The first component in the circuit is the Arduino Nano, which is a simple computer in a tiny package. This is the brain of the robot. You control the robot by writing programs that run on the Arduino.

Make sure your Arduino is the right way around, with the mini USB socket at the end of the breadboard (row 1). Place the breadboard flat on a hard surface before pushing the Arduino into the board. The pin marked D12 should be in breadboard hole H1. Some Arduinos can be very difficult to insert into the breadboard, so if you’re having problems just ask for help because you might have just received a particularly tricky one.

On each side of the breadboard there are two long rows of holes which are connected along the full length of the board. These rails are used to distribute the supply voltage to different parts of the circuit. The blue line marks the negative rail (0V); the red line marks the positive rail (6V in this circuit). The Arduino draws its power from these rails.

  • Connect a short black wire between A14 and the negative (blue) rail.
  • Connect a short red wire between A15 and the positive (red) rail.


The first thing we’ll control with the Arduino is a green light-emitting diode (LED). To do this, we’ll turn the Arduino pin marked D2 into a digital output which means that the program running on the Arduino can set it high (5V) or low (0V). When the pin is set high, a small electrical current flows through the green wire, through the green LED, and finally through the resistor to ground (the negative rail).

  • Insert a green wire between I11 and A18.
  • Insert a green LED between E18 and E19. The LED is a one-way valve for electricity, so it must be the right way around. Inside the green plastic bead, if you look carefully you’ll see that each leg is connected to a kind of a flat plate. As shown in the image below, the leg connected to the larger plate should be in E19.
  • Insert a 220 ohm resistor (colour code  RED   RED   BROWN   GOLD ) with the short legs between B19 and the negative (blue) rail.


We’re ready to run a program on the Arduino to flash the green LED on and off.

  • Double-click the Arduino icon on the desktop to launch the Arduino IDE (integrated development environment).
  • Delete the example code that appears by default in the editor.
  • Copy and paste the code below into the editor.
// RoboSlam example 1: Blink LED

// The setup routine runs once when the power is switched on.
void setup()
  // Digital output for LED on pin D2
  pinMode(2, OUTPUT);

// The loop routine runs over and over until the power is switch off.
void loop()
  digitalWrite(2, HIGH); // LED on
  delay(1000);           // 1000ms delay
  digitalWrite(2, LOW);  // LED off
  delay(1000);           // 1000ms delay

Before running the program on the Arduino Nano, you need to select the correct version of Arduino.

  • Under the “Tools” menu, enter the “Board” sub-menu and select “Arduino Nano w/ ATmega328” as shown in the image below. If that item is not listed, select “Arduino Nano” instead.
  • Under the “Tools” menu, enter the “Serial Port” sub-menu and select whatever device is listed there.
  • If the “Serial Port” sub-menu is not accessible, please ask a facilitator to check your machine because the Arduino drivers may not be set up correctly.


To download and run the program on the Arduino, click the right-facing arrow button on the toolbar of the Arduino IDE:


At this point you should hopefully see the green LED flashing on and off slowly. If it’s not and you can’t figure out why, please ask a facilitator to check what’s wrong.

Once your LED is blinking, there are four things you need to understand before moving on:

  1. How one of the Arduino pins (D2) was turned into a digital output.
  2. How the LED is turned on.
  3. How the LED is turned off.
  4. How to delay the program for a specified number of milliseconds, so that the rate of the LED blinking can be controlled.

Once you understand these four things, you have finished this part of the task (the easy part) and it’s time to move on to the LED Flash Challenge.

Part 2: LED Flash Challenge

In this part, you’re going to modify your circuit to create a simple optical transmitter, which transmits a digital message (a sequence of 1s and 0s) as a series of LED flashes.

The message that you’ll transmit will be 2 bytes long (a byte is 8 bits, or 8 ones and zeros) and it will contain your team number (byte 1) followed by a second number calculated by subtracting your team number from 255 (byte 2).

For example, if your team number is 79…

  • byte1 = 79
  • byte2 = 255 – 79 = 176
  • byte1 + byte2 = 255

Here, let me explain how binary numbers work…

Try doing some independent research on binary numbers. There’s lots more great stuff on YouTube, Wikipedia, etc.

Specifically, you need to do the following:

  1. Modify the code to create a second digital output pin.
  2. Extend the circuit by adding a second LED (with current limiting resistor) to that digital output pin.
  3. Convert your team number into an 8-bit binary number. This is byte 1 of your message.
  4. Calculate the required value of byte 2 (so that byte1+byte2 = 255) and write it as an 8-bit binary number.
  5. Each byte will be transmitted as a sequence of ones and zeros, preceded by a start bit (1) and followed by a stop bit (0). That means your complete transmission will be 20 bits long. You should calculate this sequence ad write it down on paper first.
  6. To transmit a 1, turn LED1 off and LED2 on for 500ms.
  7. To transmit a 0, turn LED2 off and LED1 on for 500ms.
  8. To ensure the sequence is read correctly, transmit a long sequence of zeros (for about 5 seconds) before you transmit your message.
  9. As is typically the case in digital transmissions, each byte must be transmitted least significant bit first.

Let’s consider that example team number 79 again. As explained above, byte 1 is 79 and byte 2 is 146.

  • Before transmitting the sequence, send a “0” for about 5 seconds.
  • The first bit of the sequence is the start bit for byte 1 which is “1”.
  • Written as a binary number, 79 (seventy-nine) is 0b01001111. The “0b” prefix indicates that a number is being written in binary form – it’s not part of the number value. The byte is transmitted least significant bit first, i.e. in the following order: “1,1,1,1,0,0,1,0”.
  • The next bit is the stop bit for byte 1, which is “0”.
  • The next bit is the start bit for byte 2, which is “1”.
  • Written as a binary number, 216 is 0b10110000, so the next 8 bits are “0,0,0,0,1,1,0,1”.
  • The final bit is the stop bit for byte 2, which is “0”.

To summarise, the complete 20-bit sequence for team 79 would be as follows:


The validator for checking your transmission is a web application which I have posted at the following location:

I will set up a validation station in KEG-036 where you can record your result once your circuit is working. Other tutors will hopefully set up validation stations in the other rooms, but that may depend on the final rooms allocated as well as available cameras and light levels.

You are welcome to try the validator on your own laptop / PC. In principle, it should work on any modern PC with a webcam and up-to-date browser. However, since video capture is relatively new in HTML, I recommend using the current release of Google Chrome which is what I tested it in. Some people have successfully used it in the web browser on their phone.

Your tutor will be able to clarify anything you don’t understand about this.

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s