انتقل للمحتوى
Robo EgyptRobo Egypt
☰ Course contents
Robo Maker: home
0. Lab tour1
1. The start: the Arduino6
2. Wiring and the traffic light4
3. Inputs: the button4
4. Sound and movement5
5. Sensors and numbers5
6. Distance, the screen and colours5
7. Motors and the car4
8. The project: the city's smart gate3
9. From blocks to C++ code5
10. Sensors and screens in code5
11. Smart systems5
12. Bluetooth: control from the phone1

A heart on the matrix

Section 10: Sensors and screens in codeLesson 10.3 · ⏱ 8 min

The 8×8 matrix has 64 LEDs. We write each row as a binary number: 1 on and 0 off. setRow draws a row.

⚙️ Drawing a heart with eight rows
#include <LedControl.h>

LedControl lc = LedControl(12, 11, 10, 1);

byte heart[8] = {B00000000, B01100110, B11111111, B11111111, B11111111, B01111110, B00111100, B00011000};

void setup() {
  lc.shutdown(0, false);
  lc.setIntensity(0, 8);
  lc.clearDisplay(0);
}

void loop() {
  for (int r = 0; r < 8; r++) {
    lc.setRow(0, r, heart[r]);
  }
}
The heart on the matrix
The heart on the matrix
🖥️ What happens on the stage?
We ran this code in Robo Maker and the challenge passed: “Bravo! It works”.
💡 Tip
Draw the heart first on 8×8 squared paper, then turn every row into 0s and 1s.

📌 Another example: a smiley face

Eight rows, each with 8 dots: 1 = on, and 0 = off.

⚙️ A smiley face
#include <LedControl.h>

LedControl lc = LedControl(12, 11, 10, 1);

byte img[8] = {B00111100, B01000010, B10100101, B10000001, B10100101, B10011001, B01000010, B00111100};

void setup() {
  lc.shutdown(0, false);
  lc.setIntensity(0, 8);
  lc.clearDisplay(0);
}

void loop() {
  for (int r = 0; r < 8; r++) {
    lc.setRow(0, r, img[r]);
  }
}
😊 on the matrix
😊 on the matrix
✍️ Practise
Draw a heart, then a smiley face.
✍️ Practise here in the lessonor open the lab in a new page ↗

🎯 Challenge yourself

Easy

An arrow pointing up.

👀 Show the solution
⚙️ Solution
#include <LedControl.h>

LedControl lc = LedControl(12, 11, 10, 1);

byte img[8] = {B00011000, B00111100, B01111110, B11011011, B00011000, B00011000, B00011000, B00011000};

void setup() {
  lc.shutdown(0, false);
  lc.setIntensity(0, 8);
  lc.clearDisplay(0);
}

void loop() {
  for (int r = 0; r < 8; r++) {
    lc.setRow(0, r, img[r]);
  }
}
In the lab
In the lab

Result: an arrow ⬆.

Medium

A square (just the frame).

👀 Show the solution
⚙️ Solution
#include <LedControl.h>

LedControl lc = LedControl(12, 11, 10, 1);

byte img[8] = {B11111111, B10000001, B10000001, B10000001, B10000001, B10000001, B10000001, B11111111};

void setup() {
  lc.shutdown(0, false);
  lc.setIntensity(0, 8);
  lc.clearDisplay(0);
}

void loop() {
  for (int r = 0; r < 8; r++) {
    lc.setRow(0, r, img[r]);
  }
}
In the lab
In the lab

Result: a square frame.

Hard

The heart beats: it shows for half a second and disappears for half a second.

👀 Show the solution
⚙️ Solution
#include <LedControl.h>

LedControl lc = LedControl(12, 11, 10, 1);

byte img[8] = {B00000000, B01100110, B11111111, B11111111, B11111111, B01111110, B00111100, B00011000};

void setup() {
  lc.shutdown(0, false);
  lc.setIntensity(0, 8);
  lc.clearDisplay(0);
}

void loop() {
  for (int r = 0; r < 8; r++) {
    lc.setRow(0, r, img[r]);
  }
  delay(500);
  lc.clearDisplay(0);
  delay(500);
}
In the lab
In the lab

Result: a heart that appears and disappears.

Finished the lesson? Mark it so your progress counts.