Lightino Lesson 1: Let's make patterns!

How to drive the LEDs

We're now ready to start the fun! But first we need to understand how the LEDs work.

Each of the 8 LEDs is actually 3 LEDs in one package: a red, a green and a blue. Each has 2 connections: the anode (the positive one) and the cathode (the negative). All the red cathodes are connected together and all the green cathodes and all the blue cathodes. All 3 anodes in each package are connected together.

LED diagram

You can activate either the red or the green or the blue cathodes by writing something like digitalWrite(RED, HIGH). You can then activate whichever anodes you like by things like digitalWrite(LED1, HIGH). Only when you've done both will anything light up.

Your new sketch

In your Arduino folder, create a new folder called Pattern1. Copy into it the file Pattern1.ino from the zip file in the introduction.

In the Arduino IDE, click File - Sketchbook. You should see your new sketch Pattern1 which you can open.

Take a look at the function loop(). We saw that this is called repeatedly for ever, but within it are 3 more loops. We can summarise them in "pseudocode" (pretend computer code just to help us understand what's going on) as follows:

Do 20 times:

Do for each colour:

Switch on the colour (cathode)
Do 8 times:
Turn on the next LED then wait a bit
Turn off all the LEDs
Turn off the colour.

Then there's another set of 3 loops doing something similar, but this time it draws diamonds. Can you see how it does it?

Now over to you! Can you change it to make hollow diamonds?

Continue to Lesson 2 by clicking here!

If you're stuck try reading the Help Sheet!

Previous article Lightino Lesson 4: Let's display messages!

Check out our latest products...

RFID Qwiic Reader (SEN-15191) - RFID

RFID Qwiic Reader (SEN-15191)

£16.00 inc VAT
£13.33 ex VAT
Battery Holder - 2 x AA with a 2 Pin JST Connector for BBC micro:bit - Accessories
RFID Qwiic Kit (KIT-15209)

RFID Qwiic Kit (KIT-15209)

£46.99 inc VAT
£39.16 ex VAT
SparkFun Thing Plus - ESP32 WROOM (WRL-14689) - WiFi
24V Step-Up/Step-Down Voltage Regulator S18V20F24
Proximity Sensor Breakout - 20cm VCNL4040 (Qwiic) (SEN-15177) - Qwiic
GPIO Expander Bonnet - 16 Additional I/O over I2C (ID:4132) - Accessories and Breakout Boards
Klip Halo V2.0 with 2x AA Battery Holder - Wearable

Klip Halo V2.0 with 2x AA Battery Holder

£7.98 inc VAT
£6.65 ex VAT