This is the next part of our Arduino tutorial series and this time we will learn and use arrays to create a small Christmas ornament with various flashing sequences. This would be the perfect project to keep the kids busy if you want to teach them the basics of soldering — just mount the LEDs on a piece of card and you can be powered by a standard 9V battery.
It’s also a key lesson in Arduino programming for beginners, although unless you’re planning on using it as a decoration, I’d highly recommend using it anyway.
Note. This is a tutorial for beginners, and we certainly will not open new paths — is it? just a device to teach how to use arrays and For loops to work with lots of LEDs (or other output devices).
If you haven’t already, now is the time to follow the other articles in the series:
- What is an Arduino and what can you do with it ?
- What is an Arduino starter kit and what does it contain?
- More cool components to buy with your starter kit
- Getting started with your Arduino starter kit? Installing Drivers and Configuring the Board and Port
- Fritzing, a free circuit diagram drawing tool
- A Closer Look at the Arduino Application Structure and Blink Sample Program
For this project, you will need at least 8 or 9 LEDs red or green, resistor for each of them, bread board and some connecting wires. The starter kit from Ooomlout, which I recently purchased myself and is pictured in this tutorial, offers great value for money and has more LEDs and resistors than you’ll ever need, and comes with a neat breadboard and Arduino case for storage. careful.
Here’s the last thing:
And a video of it in action.

Here is a view of the wiring from Fritzing. It’s very simple — just connect the positive lead of the LEDs to the pins 2-> whatever (up to pin 13) and connect the negative legs to ground built into the resistor. The value I have used here is 560 ohms. That’s it for wiring.
In terms of software, think about how you can write all those LEDs in code. You can do it like this:
int led1 = 2; // первый светодиод на контакте 2
int led2 = 3; // второй на контакте 3
// и т. д.
void loop () {
digitalWrite (LED1, HIGH);
задержки (100);
digitalWrite (LED1, LOW);
задержки (100);
digitalWrite (LED2, HIGH);
// так далее
}
You should see that with 9 LEDs this will tire you out quickly. The answer lies in arrays which if you can’t remember our Programming 101 about basic data types — mostly just lists.