Orion Schemenauer

B.S. Software Engineering

  Home

LED Matrix

I created a LED matrix to teach myself about multiplexing. An arduino controls the LEDs.

Basically, one pin controls each row of LEDs and one pin controls each column. When the pin connected to the anode of an LED is set to be a high output pin (in this case one of the "row" pins) and a pin connected the cathode of an LED is set to be an input pin (in this case the "column" pins), the LED at the intersection of the row and column pins turns on. It turned out great, but seemed useless. To increase the complexity and make it more useful, I modified the project to accept commands over serial. The arduino plays a pattern on the 4x4 grid when "start" is sent. A user can send "stop" to turn the LEDs off. Here is the arduino code:

uint8_t column[4] = { 3, 4, 5, 6 };
uint8_t row[4]    = { 10, 9, 8, 7 };

unsigned long animationSpeedMillis = 100;
const uint8_t frames = 16;...
    
Show Full Code...

Here is the Python (I was using 2.7) code which will send a serial command to the Arduino. The command sent will be whatever is passed as the first argument to the program. For example, you could run it with "python3 scriptName.py start" or "python scriptName.py stop".

import serial
import sys

s = serial.Serial(
  port='/dev/cu.usbserial-ADAOGMM2t',
  baudrate=57600
)

print "sent"
s.write(sys.argv[1])
s.readline()

s.close()
  

Here is the diagram for a 3x3 matrix from http://www.multiwingspan.co.uk/arduino.php?page=matrix:

Pins 5,6,7 and 8,9,10 get connected to the corresponding digital pins on an arduino. Although my matrix is 4x4, the principle is the same - only with two more pins and 7 more LEDs.

© Orion Schemenauer