
I think this’ll be the start of a few more projects for me. I’ve seen some cool LED PoV stuff (Persistance of Vision) with mounting displays on bikes, so hopefully I’ll get round to doing something like that.
Anyway as a start I’ve got 5 LED’s connected to 5 pins on the Arduino, nothing complex there. The real struggle is to work out the timings, or rather the pauses between the patterns. Starting with how to make a character or drawing.
Arduino POV LED parts
Arduino Deumilanove w/ ATMEGA328
Breadboard / Prototyping board
Jumper/ Connector wires
5 x LED (All the same colour!)
5 x 220 Ohm resistor (Red, Red, Brown, Gold)
Using my knowledge of graphics etc.. the logical way to do this is to use a grid of pixels and I’ll have the column of LED’s change quickly to represent each column of the grid or frame. The effect will be that at a certain speed this should look like a grid of of LED’s rather than a lonely column.
So we have a grid as below:
pin 3: 10001
pin 4: 01010
pin 5: 00100
pin 6: 01010
pin 7: 10001
This shows a cross drawing, but you can make letters or drawings etc.. once you figure this out. This is the hardest bit of the process to grasp and I’ll try and explain the code.
We need to first set our LED’s as an output, the number of LED’s is how many rows are in your grid, once this is done we need to define how many columns are in our grid.
Then we define an array of a sequence of 0′s and 1′s to say when to turn on and off the LED’s and we use a for loop to run through the number of rows against the array. After this count is finished we then loop through the number of columns to move on to the next chunk of the array. If the array is a 0, then LED is low otherwise set it to HIGH. Until we reach the end of the array and we start again. You should be able to see/ understand this from my code comments below. If you want to add more letters then you can add in another frame, just keep adding to the sequence though.
Arduino LED POV Circuit
Nothing too fancy just 5 LED’s in a line (longer terminal is +, shortest is – ), a 220 Ohm resistor between the + pin and the Arduino pin and the – pin going to GND on the Arduino.
LED Persistance of Vision Code
int setPins[] = {7,6,5,4,3}; // an array of pins/ outputs for the LEDs
int rows = 5; // number of LED's
int columns = 5; // number of columns
int numberOfFrames = 1; // number of frames
// 10001
// 01010
// 00100 = the array of 1,0,0,0,1, 0,1,0,1,0, 0,0,1,0,0, 0,1,0,1,0, 1,0,0,0,1
// 01010
// 10001
// draws a cross: 1,0,0,0,1 = pin3 on, pin4 off, pin5 off, pin6 off, pin7 on etc... count to the number of rows (5) then start again at pin3.
// repeat. add to this to add more letters
int drawing[] = {1,0,0,0,1, 0,1,0,1,0, 0,0,1,0,0, 0,1,0,1,0, 1,0,0,0,1};
void setup()
{
// for each pin set in the array set it as an output
for (int countPins = 0; countPins < rows; countPins++) {
pinMode(setPins[countPins], OUTPUT);
}
}
void loop()
{
// for each frame/ drawing
for (int countFrames = 0; countFrames < numberOfFrames; countFrames++)
{
// loop through each column
for (int countColumns = 0; countColumns < columns; countColumns++)
{
// then loop through each row in each column
for (int countRows = 0; countRows < rows; countRows++)
{
// figure out if the LED is meant to be on or off
// find the value of the item in the drawings array
// based on the counts to get the array position
if (drawing[countFrames*columns*rows + countColumns*rows + countRows] == 0)
{
digitalWrite(setPins[countRows], LOW);
} else {
digitalWrite(setPins[countRows], HIGH);
}
}
delay(5); // delay between showing each column
}
// then turn off all LED's
for (int countRows = 0; countRows < rows; countRows++)
{
digitalWrite(setPins[countRows], LOW);
}
delay(15); // delay between showing each frame.
}
delay(0); // delay between drawings. Set this depending on speed of movement
}
When you're done go to a dark room and shake the circuit to see the X form - I bundled the Arduino and breadboard along with a 9v battery together using an elastic band.
This content is published under the Attribution-Noncommercial-Share Alike 3.0 Unported license.
- Control a DC motor with Arduino and L293D chip
- Using Processing to Send Values using the Serial Port to Arduino
- Arduino + Processing – 3D Sensor Data Visualisation
- Arduino + Processing – Make a Radar Screen – Part 3: Visualising the Data from Sharp Infrared Range Finder
- Arduino – Using a Sharp IR Sensor for Distance Calculation
- Arduino + Processing: Make a Radar Screen to Visualise Sensor Data from SRF-05 – Part 2: Visualising the Data
- larryBot – Arduino robot versions 0.1 to 0.5 lessons learned
- Arduino – making a basic drum machine
- Arduino – IR remote/ intervalometer for Nikon D80 DSLR (that means timelapse photography yarrr!)
- Arduino: Controlling the Robot Arm
