Arduino 101 - Coding with Arduino IDE
Peter Lin, October 2022
see the bottom of the Page for the version Mick Byrne wrote and deliver in Sept 2023
Acknowledgement
We acknowledge Aboriginal and Torres Strait Islander peoples and their continuing connection to land and as custodians of stories for millennia. We respectfully acknowledge the land on which we all meet today, and pay our respects to elders past, present and emerging.
Summary
Learn about updating code and writing your own for Arduino, a great complementary workshop to our Introductory Arduino 101 basic workshop. With some basic Arduino programming skills, you can get super creative with your electronics projects.
101 skills development workshops give you the basic skills you need to start your new creative journey. Each workshop is delivered by an experienced facilitator and no prior experience required, just basic computer skills, a willingness to learn and a bit of patience.
Skills Introduced
- Dissecting example code
- 8×8 LED Matrix - Draw something
Materials
Material | Quantity | Cost |
---|---|---|
Arduino Nano V3.0 Board | 10 | $13.48 |
USB cable (included with Nano) | 10 | $0.00 |
MAX7219 Serial Dot Matrix Display Module | 10 | $9.05 |
Solderless Breadboard | 10 | $4.36 |
Solderless Breadboard Jumper Cable Wires (10 x 10) | 50 | $0.80 |
Total | $27.69 |
Tools and Preparation
- Arduino Nano
- Jumper Cables
- 8×8 LED Matrix
- Solderless Breadboard
- Laptop/ Computer
- USB Cable (to connect Arduino to computer)
- Arduino IDE installed
Workshop Walk through
Step 1
Find your reference
The best place to know where to start is to look at the library(s) that we included in our code. Usually there will be some sort of documentation along with the library. In our example sketch, we can find the included library and look for more information about it by going to Tools → Manage Libraries.
[photo of libraries panel]
To see which libraries are installed in the IDE, make sure to select the ‘Installed’ filter on the panel.
[photo showing installed]
Once we’ve found the library, click on more info.
[photo of LedControl Library]
Step 2
Try it yourself! Going through the document, we can see that to control a single LED, the command is:
lc.setLed(Adress, Row, Column, State);
Let’s give this a try. For example, let’s turn on the LED at the top left corner of the matrix. The command would be:
lc.setLed(0, 0, 0, 1);
Using this command alone, we’re able to turn on and off individual LEDs but it is not very efficient when we have to turn on more than one LED at a time, for that we can use
lc.setRow(); to turn on a whole row of LED ;or lc.setColumn(); to turn on a whole column
The previous commands are useful if we want to turn on individuals, a whole row, or column of LED. But what if we want to turn on a selected group of LEDs in a row or column? - Byte arrays. There are 8 Bits in one Byte. A bit- Binary Digit is a smallest unit of data a computer can process.. 1s and 0s.
B00000000 - This is one Byte.
Using a Byte array, we can tell our Arduino to turn on multiple LEDs on a specific row or column on our 8×8 matrix. For example, let’s turn on the 2 top left LEDs on our matrix,
The Byte array would be: B11000000
So the command would be:
lc.setRow(0, 0, B11000000);
Step 3
Build upon it Let's try to draw something using the lines we’ve just discovered.
Using the LED Matrix Editor Tool, we could also design our own graphics and copy the design in Byte arrays to display on our matrix.