Open Arduino

Enter Your Project for a chance to win a grand prize for the most innovative use of Arduino or a $200 shopping cart! The Birthday Special: Arduino Projects for Arduino Day!

Back to The Project14 homepage

Project14 Home
Monthly Themes
Monthly Theme Poll


Happy Birthday to Arduino, and Happy Birthday to Project14!


Such wonderful occasions, like the Olympics, just have to include a torch relay.


Now, being that this is a techy forum, and that we're talking about Arduino here, this particular torch relay involves passing the blink of an LED amongst boards.

Arduino Torch Relay


I find it particularly suitable because the first thing most people do when they get one of these boards is to test it out by making the LED blink.

I also found that this illustrates Arduino very well, in that it uses an input, some logic, and an output.


My project is designed to show how far Arduino has come since the original Arduino environment was started in 2003. It also is intended to show how easily a sketch can be ported across various different boards.


While my project only scratches the surface of what Arduino (and compatible) boards are available (and are capable of), it shows how much of an impact Arduino has had on myself, which may also be representative of other hobbyist type users around the world. It didn't cost me a fortune to build up this collection of various Arduino based boards, partly because of the availability of clones in this open source environment.


The Relay in Action!

Each board uses a simple LDR (photo resistor aka light sensor) (usually on A0) to detect an incoming LED light blink, and each board has an external LED (usually on D13). Most of the boards have on-board LEDs which you might notice blinking in the video, but the external LEDs make it easier to set off the light sensors of the next board in the sequence, in that we can point them at the next board's sensor.


Interestingly, one of the bigger challenges of this project was powering all 7 boards at once. I decided that I would directly plug in the Witty because of its 3.3v requirement, and also directly plug in the Genuino 101.

I then connected 5v and GND from the Genuino to a couple of power rails from breadboards, and used that to power all the other boards directly through their 5v pins.


How It Works:

Each board is a single step in the process, and each step does the exact same thing:

1. Start by doing nothing

2. Wait for the light sensor to detect brighter light

3. Wait for one second

4. Turn on the LED for one second


The reason for waiting the one second is to allow the previous board to finish its turn. Without this delay all the boards would light up nearly simultaneously.


I used one second because it makes the process a little slower and easier to see, but you could use a smaller value like 1/3 second and the lights will chase around faster.

You could also use a shorter wait time than on time. That way there will be some overlap between boards being on.


The Hardware:

Each board requires one light sensor (LDR), and one external LED. We use Arduino's internal pull-up resistor on A0 to make it work without any extra hardware.

1. The light sensor gets connected between A0 and GND

2. The LED gets connected between D13 and GND



1. Genuino 101 seems to not have an internal pull-up resistor on A0. I added a 10k resistor between A0 and 3.3v

2. Digispark uses different pin numbering. I connected the LED to pin1, which is also the standard built-in LED for that board, and I connected the LDR to P2. In the sketch it gets a little funny as the analog pins are referred to as one number lower, in this case 1, but the pinmode needs to be set on the actual pin number, being 2 here.

3. Witty already has an onboard LDR and a very bright onboard RGB LED, so it has no external hardware at all. Score +one for the Witty! I modified the sketch slightly because the LDR gave results backwards to the other boards, and I wanted to use the green LED to match the colour of the LEDs used for the other boards.


The Setup:

So it turns out that the LDRs are a bit finicky - I found I could not set them to be too sensitive in the sketch because then the room light would set them off, so I had to make sure the previous board in the sequence was positioned close enough to cause the chain reaction.

In a nutshell, align all of the boards so that the LED output of one board is nearly touching the LDR of the next board.


The Actors: (ie, the boards used for this project)

1. Arduino compatible MC-Nano - my first Arduino board, which was given to me by element14 many years ago, in 2011, after I completed an XL-Star based project in their Summer of Design competition. This board, this gift, this introduction, has had a huge impact on my life, forming a foundation for many of my hobby projects that I have built since, and will be building in the near future.

2. Arduino UNO - I would consider this the standard learning platform, with so many examples and tutorials based on this layout.

3. Generic No-name red UNO - An inexpensive no-name copy of the UNO. This to me shows the open-source, open-design advantages of the Arduino environment - allowing for a very low cost introduction to Arduino, removing barriers to all of those brilliant inventors out there who might otherwise never have the chance.

4. Arduino compatible Pro-Mini (clone) - I bought the first one of these due to it's very low price point and very small form factor. The tiny package allows it to easily be incorporated into a project where space is limited.

5. Digispark (clone) - A super-tiny Arduino board, also very low cost. I find that most of my Arduino projects don't need many GPIO pins or speed. This board is about the size of a quarter and does everything I need for many of my projects.

6. Genuino-101 (by Intel). This is a small piece of history. The Genuino was a name that came about because of legal battles within the core Arduino group. Thankfully that has since been resolved. This board follows the standard UNO form factor, and adds a lot of extra power and memory over the Atmel based boards. What is also really cool about this board is that it includes bluetooth and accelerometer/gyroscope. I believe these now just go by the name "Arduino 101".

7. Witty WiFi - while not my first venture into using ESP8266-based Arduino compatible boards, this board makes it very easy and to me represents the perfect starting point into Arduino WiFi projects.  Key features, beyond having WiFi and Arduino support, include the built-in RGB LED and light sensor, as well as a removable programming board that makes programming the Witty a simple plug-and-play operation. For this project, the built-in LED and light sensor also means there is no need for additional hardware!

ps, The Digistump Oak makes a guest appearance in this video, playing a "supportive role" to the Digispark


Actors Not in this Movie: (ie, Other boards that are significant for me but were not included)

1. ESP-01. WiFi enabled Arduino compatible. Very low cost, very tiny. Unfortunately it takes a bit more effort than I wanted to put in, to hook up an analog sensor as well as LED for this project. Plus I would have to take apart my temperature logger.

2. Other ESP8266 boards. I'll include the WeMos D1-Mini, Adafruit Huzzah, Digistump Oak, and Sonoff boards into this group - I haven't had much time to try them all out, but they are essentially all a variation on the ESP-01, and all make the ESP8266 easier to use. The Witty WiFi represents this group in the torch relay.

3. ATTiny13 chips - I've used a small surface-mount ATTiny13 for a small art project to flash an LED at specific intervals, running on a simple CR1620 battery. These things are incredibly tiny and also very limited, and it would take a lot of effort to wire one up just for this project.

4. ATTiny85 chips - I actually just received a few of these as part of a contest prize from element14. Similar to the ATTiny13, but with much better community support. I wanted to try these partly because of their internal temperature sensor. The ones I have are DIP, which is easier to test with, but also makes for a much bigger package compared to the smd ATTiny13 chips.

5. Intel Edison - This is an interesting board - very tiny as well, with amazing power, speed, and memory available. It actually runs a Linux system on it and has built-in Wifi and Bluetooth support. It has a handy programming board that comes with it, but it could be hooked up independently. Unfortunately, the connectors are very tiny and a bit unique, so I never did try it out independently. Intel has since discontinued this product, and I didn't include it in the torch relay simply because it gave me a lot of trouble getting it going again (it let me upload a sketch once, then refused to connect again. boo!)


Here is a picture showing all the above mentioned boards, which gives an idea of how they all compare in size too:

My family of Arduino based boards


Honourable Mention:

The TI Launchpad series. I bought a few of the low cost Launchpad 430s when TI was selling them for just $4.30 (with free shipping) many years ago now. While originally these could only be programmed using TI's Code Composer Studio, a group of brilliant engineers has since created Energia, which is a derivative of the Arduino environment and makes programming them essentially the same process as using an Arduino board.


The Script:

Following is the sketch I used for all the boards.

Note that there were a few minor variations:

1. Digispark handles analog input pin numbering differently and uses a different LED pin number.

2. The Witty has a built-in light sensor, but it is hooked up backwards compared to the way I did it for all the other boards. And I set it to use the green LED on pin 12 to match the others.

3. Not in the sketch, but the Genuino 101 needed a pull-up resistor. It appears that it doesn't have the same internal pull-up resistors as the standard Arduino Uno.


To set up the sketch for Witty or Digispark, simply remove the comment // marks in front of the #define (on lines 8 and 9) for one you're currently programming. Comment both out (as shown) for all the other boards.


// Arduino Birthday - Torch Relay!
// Light sensor triggers LED light on after 1 second

//#define WITTY
//#define DIGISPARK

// We might be able to use LED_BUILTIN for most
#ifdef WITTY
int LDR = A0;
int ledPin = 12; // to keep the green theme
#elif defined DIGISPARK
int LDR = 1; // Analog P2 Digispark. Analog inputs use pin number minus 1
int ledPin = 1; // Digital P1 Digispark. Also the built-in LED
int LDR = A0;      // select the input pin for the LDR. Digispark use 2 = P2, but do analogRead(1) to read it
int ledPin = 13;

/* analogread notes for digistump:     
    sensorValue = analogRead(1); //Read P2
    //To set to input: pinMode(2, INPUT);
    //THIS IS P2, P2 is analog input 1, so when you are using analog read, you refer to it as 1.

void setup() {
  // put your setup code here, to run once:

  pinMode(ledPin, OUTPUT);
  pinMode(LDR+1, INPUT_PULLUP);  // Digispark - pinMode is done on actual pin number

  digitalWrite(ledPin, LOW);   // turn the ledPin off

//  Serial.begin(115200);
//  Serial.println("Starting...");


void loop() {
  // put your main code here, to run repeatedly:

  int val = analogRead(LDR);       // read the value from the sensor

  // LDR read of < 500 = green LED ON, higher value when off, depending on room light
//  Serial.print("val = ");
//  Serial.println(val);

#ifdef WITTY
  val = 1024-val; // invert the value

  while (val > 500) {
    delay(100); // 10x per second
    val = analogRead(LDR);

#ifdef WITTY
  val = 1024-val; // invert the value

//    Serial.print("val = ");
//    Serial.println(val);

  // previous torch-bearer will be on for a second
  delay (1000);

  digitalWrite(ledPin, HIGH);  // turn the ledPin on
  delay (1000);
  digitalWrite(ledPin, LOW);   // turn the ledPin off




ps, I often just say "Arduino" to refer to the Arduino environment - the IDE and related boards. Not necessarily those from the official Arduino foundation.

pps. "Arduino" is a registered trademark of Arduino AG. Which is why only the Uno is known as an "Arduino Uno" and all the other boards are referred to as "compatible" or "clone" boards.