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 (and for some of you part of the next lab) you’ll be working with your team to complete two tasks:
- Build a simple breadboard circuit for the Arduino Nano and program it to blink an LED on and off.
- 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 10-19: DT066A Group C1 with Brian Cogan in room KEG-012
- Teams 20-29: DT066A Group C2 with Jane Courtney in room KEG-014
- Teams 30-49: DT066A Groups D1 & D2 with Ted Burke and Catherine Fitzgerald in room KEG-036
- Teams 50-59: DT066A Group E1 with Mick McKeever in room KE4-023 (room TBC!)
Part 1: Blinking LED
This task is relatively straightforward and shouldn’t take you too long to get working. Open the link below in a new tab and follow the instructions as far as the end of Part 1. Once your LED is blinking, come back here. (Note: The LED you receive may be a different colour and/or shape to that shown in the instructions.)
Once your LED is blinking, there are four things you need to understand before moving on:
- How one of the Arduino pins (D2) was turned into a digital output.
- How the LED is turned on.
- How the LED is turned off.
- 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…
Specifically, you need to do the following:
- Modify the code to create a second digital output pin.
- Extend the circuit by adding a second LED (with current limiting resistor) to that digital output pin.
- Convert your team number into an 8-bit binary number. This is byte 1 of your message.
- Calculate the required value of byte 2 (so that byte1+byte2 = 255) and write it as an 8-bit binary number.
- 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.
- To transmit a 1, turn LED1 off and LED2 on for 500ms.
- To transmit a 0, turn LED2 off and LED1 on for 500ms.
- To ensure the sequence is read correctly, transmit a long sequence of zeros (for about 5 seconds) before you transmit your message.
- 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 a validation station in KEG-036 where you can record your result once your circuit is working. Other tutors may set up validation stations in the other rooms, but that will depend on 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.