# Simple Arduino Dot-Matrix Monitor

2,959

12

1

## Introduction: Simple Arduino Dot-Matrix Monitor

Nowadays there are many Dot-matrix displays on top of stores or this sort of places.
Dot-matrix has a simple idea behind, to make and display with LED or lamp dots.
In this guide I wanna to show you how to make a beginner and simple dot-matrix with Arduino.

## Step 1: Connect the Parts

Used parts:
- 16x LED
- 4x Resistor between 100 To 1K
- 1x Arduino (I've used an Uno)
- Wires

In dot-matrix we will use a LED for each pixel.
It seems really simple, but instead of separate wiring to LEDs, we should use shared bus.

According to attached picture, I've used a shared bus (wire) for each row and each column in a 4x4 rectangular form.

Cathodes are connected as columns and Anodes as rows.

Now, we have 8 wires to control 16 LEDs.
Connect the wires to pins 2 to 9 of arduino.

Use the resistors on cathode wires.

## Step 2: Arduino Code

Open the arduino console and type the code.
Help:
- pinmode commands are used to declare the pins as output.
- randomseed and random functions are used to make proper random numbers.
- digitalwrite commands are used to send a positive or negative signal to output.
- delay used at the end of loop to make sure we have enough time to see each state on LEDs.

void setup(){
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);

}

void loop(){

digitalWrite(2, random(0, 10)<5 ? HIGH : LOW);
digitalWrite(3, random(0, 10)<5 ? HIGH : LOW);
digitalWrite(4, random(0, 10)<5 ? HIGH : LOW);
digitalWrite(5, random(0, 10)<5 ? HIGH : LOW);
digitalWrite(6, random(0, 10)<5 ? HIGH : LOW);
digitalWrite(7, random(0, 10)<5 ? HIGH : LOW);
digitalWrite(8, random(0, 10)<5 ? HIGH : LOW);
digitalWrite(9, random(0, 10)<5 ? HIGH : LOW);

delay(50);
}

## Recommendations

A very good instructable for the beginner!

This is an excellent example of how a simple beginning becomes rather complex quickly with a very steep learning curve! Let me explain... Suppose we built this circuit and we wanted to display a 'bouncing ball' instead of a random light display.

The first problem one runs into is how does one set a particular LED on/off?

This is solved by restructuring the program and providing a ON(row,col) and a OFF(row,col) routine (and one can also provide sister routines IS_ON(row,col) and IS_OFF(row,col) which return true or false). To do this we will want to move the multiplexing of the LEDs to an interrupt routine so the LED brightnesses are uniform and so the Loop routine doesn't have to worry so much about looping quickly and therefore can focus on calling the ON and OFF routines.
We will also want to write directly to the ports as opposed to using the very SLOW digitalWrite calls.

It is wonderful that your circuit is great at showing the ease of making a random light display, and with no hardware modifications, we can make a bouncing ball, etc. only by changing the code. Also the programmer who starts from a beginning random display has to quickly learn about much more advanced concepts like interrupt routines and direct port access in order to implement what might seem like a simple next step - to make one LED light, then another, etc. as in a bouncing ball.

It would be nice if you demonstrated this in a future update!

btw: that Arduino can't source much power (40 ma or so through all pins) through its pins, so you will probably have troubles if your random display attempts to light too many LEDs simultaneously!