Module 3 - Matrix

Meet Matrix:  Matrix is a new character on the Island of PodPi.  She represents a 8 x 8 LED matrix device that can be used to display pixel art and small animated pixel art.

What is a Matrix?

A Matrix has 64 small LEDs arranged in a grid of 8 rows and 8 columns.  Each LED can be controlled independently.  There is a special microchip that handles all the work from communication to display of each LED.

How does it work?

Each single LED is connected at a row and column intersection.  When a high signal (1) is present on a row and a low signal (0) is present on a column, the LED at that intersection will light up because of the difference in voltage.

No resistors are necessary - all resistors are in the microchip already.

You can send commands to control single LEDs and the microchip is responsible for coordinating all LEDs.  This particular matrix uses the I2C protocol (also called Two Wires Interface) to receive the commends from the Arduino board.

Your code

Use your editor to create your program.  Use "nano" on Mac or "notepad" on PC.  You can give your script (program) the name you want.  Make sure to use the same name when you execute it with node.

The comments in the code (the parts in grey) are not necessary, but they will help you understand the code better.  Having problem with this challenge?  Let me know about it by filling this form.

/* Welcome to Edition 2, Challenge 1

Title:     The Color Selector
Edition:   2
Challenge: 1
Author:    Reggie

Description: Help Leddy and Reggie make a color selector
for their fireworks using three tactile switches to control
each color.

// Setup the johnny-five library
var five = require('johnny-five');
var board = new five.Board();

// When the board is ready, run this function
board.on('ready', function() {

  var red = new five.Led(9);    // red on Digital Pin 9
  var blue = new five.Led(10);  // blue on Digital Pin 10
  var green = new five.Led(11); // green on Digital Pin 11

  var push_red = new five.Button("A2");   // button on Analog Pin A2
  var push_green = new five.Button("A1"); // button on Analog Pin A1
  var push_blue = new five.Button("A0");  // button on Analog Pin A0

  // when button Red is pushed, toggle the red LED
  push_red.on('press', function() {

  // when button Green is pushed, toggle the green LED
  push_green.on('press', function() {

  // when button Blue is pushed, toggle the blue LED
  push_blue.on('press', function() {


Next Experiment

Replace the "toggle()" call with a call to "pulse(1000)" and see what happens.