what:
a 5*5 rgb led matrix, made with arduino and lpd6803 based leds from adafruit.
with an pir sensor, it goes on if it detects movements and a ir distace sensor, 1 animation shows the distance you have from the sensor :).
movie1
why:
because its beautiful and cool ;)
my spelling:
well, sorry if i make stupid spelling mistakes, i'm dyslectic and live in Holland
a 5*5 rgb led matrix, made with arduino and lpd6803 based leds from adafruit.
with an pir sensor, it goes on if it detects movements and a ir distace sensor, 1 animation shows the distance you have from the sensor :).
movie1
because its beautiful and cool ;)
my spelling:
well, sorry if i make stupid spelling mistakes, i'm dyslectic and live in Holland
Step 1: How It Works
how it works:
it uses an arduino uno that controls the lpd6803 chips in the rgb leds, so i can set each led individually. the arduino reads text files from an sd card, i've made a program(in c#) where you can make animations and store them so the arduino can read them.
it uses an arduino uno that controls the lpd6803 chips in the rgb leds, so i can set each led individually. the arduino reads text files from an sd card, i've made a program(in c#) where you can make animations and store them so the arduino can read them.
Step 2: Materials Needed
materials:
-arduino uno (other arduino's probbably work, but i havent tested)
-25 rgb leds with lpd6803 controllers( the led's i used arent being saled anymore :( these are an newer version, but you will need to adapt the arduino code a bit)
-network shield(for sd card)(probably other shields with sd cards wil work)
-5v dc power supply min 1A
optionally:
-ir distance senso r (1 animation uses it)
-pir senso r (the matrix will go on if it detects motion(saves a bit of energy))
-2 pushbuttons
tools:
-soldering iron
-wire stripper
-some wires
-wooden board
-arduino uno (other arduino's probbably work, but i havent tested)
-25 rgb leds with lpd6803 controllers( the led's i used arent being saled anymore :( these are an newer version, but you will need to adapt the arduino code a bit)
-network shield(for sd card)(probably other shields with sd cards wil work)
-5v dc power supply min 1A
optionally:
-ir distance senso r (1 animation uses it)
-pir senso r (the matrix will go on if it detects motion(saves a bit of energy))
-2 pushbuttons
tools:
-soldering iron
-wire stripper
-some wires
-wooden board
Step 3: Part With Wood
this is the part im bad at, but ill discribe what ive done:
iv'e put my led's 5cm apart (horizontally and vertically) in a shiny wooden plate from an old kitchen.
the led's from adafruit need 11mm holes(drill them carfully).
at the bottom ive place my arduino with double-sided thape, and left of it a big hole for the pir sensor, the ir distance sensor is placed on top(now it looks like it has eyes ;) )
then put the led's in the holes beginning top left(frot vieuw) going from left to right down(see picture)
iv'e put my led's 5cm apart (horizontally and vertically) in a shiny wooden plate from an old kitchen.
the led's from adafruit need 11mm holes(drill them carfully).
at the bottom ive place my arduino with double-sided thape, and left of it a big hole for the pir sensor, the ir distance sensor is placed on top(now it looks like it has eyes ;) )
then put the led's in the holes beginning top left(frot vieuw) going from left to right down(see picture)
Step 4: The Electronics
for the leds
wiring
led's clock --> 6
led's data --> 7
pir sensor --> A5 (if you have no pir sensor, connect it to the 5v+)
ir distance sensor -->A4 (if you don't have a distance sensor juslt leave it open)
gnd --> Button 1 --> A0
gnd --> Button 2 --> A1
sd: (the default of the ethernet shield)
mosi --> 11
miso --> 12
clk --> 13
cs --> 4
power:
ir distance senor + -----> all to arduino's 5v+
pir+
ir distance sensor -
pir - -----> all to arduino's gnd
negative from 5v power supply
led's -
button -
led's + ----> positive from 5v power supply
----------------------------------------------------------------
all black cables are soldered together as central gnd
all red cables(exept one) are soldered together as sensor 5v+ (from arduino)
all yellow cables are signal cables(watch it are 5 yellows so don't mix them up!!)
----------------------------------------------------------------
you also find mine animations here, just put them on the sd card
wiring
led's clock --> 6
led's data --> 7
pir sensor --> A5 (if you have no pir sensor, connect it to the 5v+)
ir distance sensor -->A4 (if you don't have a distance sensor juslt leave it open)
gnd --> Button 1 --> A0
gnd --> Button 2 --> A1
sd: (the default of the ethernet shield)
mosi --> 11
miso --> 12
clk --> 13
cs --> 4
power:
ir distance senor + -----> all to arduino's 5v+
pir+
ir distance sensor -
pir - -----> all to arduino's gnd
negative from 5v power supply
led's -
button -
led's + ----> positive from 5v power supply
----------------------------------------------------------------
all black cables are soldered together as central gnd
all red cables(exept one) are soldered together as sensor 5v+ (from arduino)
all yellow cables are signal cables(watch it are 5 yellows so don't mix them up!!)
----------------------------------------------------------------
you also find mine animations here, just put them on the sd card
Step 5: Arduino's Program
well, im not the bast at programming, but it works ;)
this is the code i used, you can download it here, feel free to hack/mod.(and post nice pictures of it ;) )
#include <TimerOne.h>
#include <SD.h>
#include "LPD6803.h"
int raw;
int dat[6];
int nr = -1;
int rgb = 1;
int digit = 0;
int kleur[100][3];
int beeld = 7;
int teller = 0;
int wachttijd = 1000;
int wachtuit = 0;
int talleur = 0;
int beweging = 1;
int beatdet = 0;
File dataFile;
const int chipSelect = 4;//sd stuff
LPD6803 strip = LPD6803(25, 7, 6);//starts the lpd strip
void setup()
{
Serial.begin(9600);
Serial.print("Initializing SD card...");
strip.setCPUmax(60);//start de ledstrip
strip.begin();
strip.show();
pinMode(10, OUTPUT);//for the sd
if (!SD.begin(chipSelect)) {
Serial.println("Card failed, or not present");
// don't do anything more:
settm(5,31,0,0);
return;
}
Serial.println("card initialized.");
}
void loop()
{
// talleur = 1;
if (beweging == 1){
leesSD(talleur);
if (talleur == 49)afstandanim(); // if you don't have an ir distance sensor you can delete this line
talleur++;
}
if (talleur > 50) { //motion detection
beweging = 0;
Serial.print(" analogReadA5:");
Serial.println(analogRead(A5));
if (analogRead(A5) > 300){
beweging = 1;
talleur = 0;
}else{
clearall();
}
}
}
void afstandanim(){
Serial.println("afstandanim");
for (int e = 0; e < 100; e++){
Serial.print("afstand:");
int q = analogRead(A4);
Serial.println(q);
delay(100);
int w = (q / 20)-2;
clearall();
settm(w,31,31,31);
if (digitalRead(A0) == 0){while(digitalRead(A0) == 0){delay(10);}if (talleur == 1)talleur = 49; talleur--; talleur--; break;} //buttons
if (digitalRead(A1) == 0){while(digitalRead(A1) == 0){delay(10);} break;}
}
}
void leesSD (long textnr){
nr = 0;
rgb = 1;
digit = 0;
dat[0] = 0;
dat[1] = 0;
dat[2] = 0;
dat[3] = 0;
char FileName[7];
sprintf( FileName, "an%i.an", textnr );//opens the right textfile
dataFile = SD.open(FileName);
rgb = 1;
if (dataFile) {
while (1==1){
raw = (dataFile.read() - 48);
if (raw == -4){//,
if (nr != 25){
kleur[nr][rgb] = dat[1] + (dat[0] * 10);}
rgb = 1;
nr++;
digit = 0;
dat[0] = 0;
dat[1] = 0;
}
if (raw == -16){// space
if (nr != 25) kleur[nr][rgb] = dat[1] + (dat[0] * 10);
digit = 0;
dat[0] = 0;
dat[1] = 0;
dat[2] = 0;
dat[3] = 0;
rgb++;
}
if (raw == -10){//&
Serial.print("next frame:");
delay(10);
wachttijd = dat[4] + dat[3] * 10 + dat[2] * 100 + dat [1] * 1000;
Serial.println(wachttijd);
rgb = 1;
digit = 0;
dat[0] = 0;
dat[1] = 0;
dat[2] = 0;
dat[3] = 0;
setkleuren();
if (beatdet == 0){
delay(wachttijd);}else{
int val = 0;
double gewacht = 0;
if (wachttijd != 10){
while (1 == 1){
delay(10);
val = analogRead(A0);
delay(10);
Serial.println("________");
Serial.println(analogRead(A0));
Serial.println(val);
Serial.println("__________");
if (analogRead(A0) > val + 5){
Serial.println("beat!");
break;}
gewacht ++;
if (gewacht > wachttijd / 100) {break;
gewacht = 0;
}}}}
if (digitalRead(A0) == 0){while(digitalRead(A0) == 0){delay(10);}if (talleur == 1)talleur = 49; talleur--; talleur--; break;}
if (digitalRead(A1) == 0){while(digitalRead(A1) == 0){delay(10);} break;}
nr = 0;
}
if (raw == 36){//T
wachtuit = 1;
digit = 0;
rgb = 1;
dat[1] = 0;
dat[2] = 0;
dat[3] = 0;
dat[4] = 0;
setkleuren();
}
if (raw == 15){//?
Serial.print("ready with animation number:");
Serial.println(talleur);
break;
rgb = 1;
}
if (raw >= 0){//getallen
if (rgb == 4)rgb = 1;
dat[digit] = raw;
digit++;
}
}
dataFile.close();
}
// if the file isn't open, pop up an error:
else {
Serial.println("error opening ***.txt");
}
}
void setkleuren() { //zet alle kleuren uit ledkleur[][]
for (int i=-1; i <= 25; i++){
strip.setPixelColor(i, Color(kleur[i][3] , kleur[i][1] , kleur[i][2]));
}
strip.show();
}
void clearall() {// cleart de hele strip
//lednr = 0;
for (int i=0; i <= 25; i++){
kleur[i][1] = 0;//r
kleur[i][2] = 0;//g
kleur[i][3] = 0;//b
}
setkleuren();
}
void settm(int tm, int r, int g, int b) {// cleart de hele strip
//lednr = 0;
for (int i=0; i <= tm; i++){
kleur[i][1] = r;//r
kleur[i][2] = g;//g
kleur[i][3] = b;//b
}
setkleuren();
}
unsigned int Color(byte r, byte g, byte b) // maakt een getal van de r b en g waardes (hoort bij de ledstrip)
{
//Take the lowest 5 bits of each value and append them end to end
return( ((unsigned int)g & 0x1F )<<10 | ((unsigned int)b & 0x1F)<<5 | (unsigned int)r & 0x1F);
}
this is the code i used, you can download it here, feel free to hack/mod.(and post nice pictures of it ;) )
#include <TimerOne.h>
#include <SD.h>
#include "LPD6803.h"
int raw;
int dat[6];
int nr = -1;
int rgb = 1;
int digit = 0;
int kleur[100][3];
int beeld = 7;
int teller = 0;
int wachttijd = 1000;
int wachtuit = 0;
int talleur = 0;
int beweging = 1;
int beatdet = 0;
File dataFile;
const int chipSelect = 4;//sd stuff
LPD6803 strip = LPD6803(25, 7, 6);//starts the lpd strip
void setup()
{
Serial.begin(9600);
Serial.print("Initializing SD card...");
strip.setCPUmax(60);//start de ledstrip
strip.begin();
strip.show();
pinMode(10, OUTPUT);//for the sd
if (!SD.begin(chipSelect)) {
Serial.println("Card failed, or not present");
// don't do anything more:
settm(5,31,0,0);
return;
}
Serial.println("card initialized.");
}
void loop()
{
// talleur = 1;
if (beweging == 1){
leesSD(talleur);
if (talleur == 49)afstandanim(); // if you don't have an ir distance sensor you can delete this line
talleur++;
}
if (talleur > 50) { //motion detection
beweging = 0;
Serial.print(" analogReadA5:");
Serial.println(analogRead(A5));
if (analogRead(A5) > 300){
beweging = 1;
talleur = 0;
}else{
clearall();
}
}
}
void afstandanim(){
Serial.println("afstandanim");
for (int e = 0; e < 100; e++){
Serial.print("afstand:");
int q = analogRead(A4);
Serial.println(q);
delay(100);
int w = (q / 20)-2;
clearall();
settm(w,31,31,31);
if (digitalRead(A0) == 0){while(digitalRead(A0) == 0){delay(10);}if (talleur == 1)talleur = 49; talleur--; talleur--; break;} //buttons
if (digitalRead(A1) == 0){while(digitalRead(A1) == 0){delay(10);} break;}
}
}
void leesSD (long textnr){
nr = 0;
rgb = 1;
digit = 0;
dat[0] = 0;
dat[1] = 0;
dat[2] = 0;
dat[3] = 0;
char FileName[7];
sprintf( FileName, "an%i.an", textnr );//opens the right textfile
dataFile = SD.open(FileName);
rgb = 1;
if (dataFile) {
while (1==1){
raw = (dataFile.read() - 48);
if (raw == -4){//,
if (nr != 25){
kleur[nr][rgb] = dat[1] + (dat[0] * 10);}
rgb = 1;
nr++;
digit = 0;
dat[0] = 0;
dat[1] = 0;
}
if (raw == -16){// space
if (nr != 25) kleur[nr][rgb] = dat[1] + (dat[0] * 10);
digit = 0;
dat[0] = 0;
dat[1] = 0;
dat[2] = 0;
dat[3] = 0;
rgb++;
}
if (raw == -10){//&
Serial.print("next frame:");
delay(10);
wachttijd = dat[4] + dat[3] * 10 + dat[2] * 100 + dat [1] * 1000;
Serial.println(wachttijd);
rgb = 1;
digit = 0;
dat[0] = 0;
dat[1] = 0;
dat[2] = 0;
dat[3] = 0;
setkleuren();
if (beatdet == 0){
delay(wachttijd);}else{
int val = 0;
double gewacht = 0;
if (wachttijd != 10){
while (1 == 1){
delay(10);
val = analogRead(A0);
delay(10);
Serial.println("________");
Serial.println(analogRead(A0));
Serial.println(val);
Serial.println("__________");
if (analogRead(A0) > val + 5){
Serial.println("beat!");
break;}
gewacht ++;
if (gewacht > wachttijd / 100) {break;
gewacht = 0;
}}}}
if (digitalRead(A0) == 0){while(digitalRead(A0) == 0){delay(10);}if (talleur == 1)talleur = 49; talleur--; talleur--; break;}
if (digitalRead(A1) == 0){while(digitalRead(A1) == 0){delay(10);} break;}
nr = 0;
}
if (raw == 36){//T
wachtuit = 1;
digit = 0;
rgb = 1;
dat[1] = 0;
dat[2] = 0;
dat[3] = 0;
dat[4] = 0;
setkleuren();
}
if (raw == 15){//?
Serial.print("ready with animation number:");
Serial.println(talleur);
break;
rgb = 1;
}
if (raw >= 0){//getallen
if (rgb == 4)rgb = 1;
dat[digit] = raw;
digit++;
}
}
dataFile.close();
}
// if the file isn't open, pop up an error:
else {
Serial.println("error opening ***.txt");
}
}
void setkleuren() { //zet alle kleuren uit ledkleur[][]
for (int i=-1; i <= 25; i++){
strip.setPixelColor(i, Color(kleur[i][3] , kleur[i][1] , kleur[i][2]));
}
strip.show();
}
void clearall() {// cleart de hele strip
//lednr = 0;
for (int i=0; i <= 25; i++){
kleur[i][1] = 0;//r
kleur[i][2] = 0;//g
kleur[i][3] = 0;//b
}
setkleuren();
}
void settm(int tm, int r, int g, int b) {// cleart de hele strip
//lednr = 0;
for (int i=0; i <= tm; i++){
kleur[i][1] = r;//r
kleur[i][2] = g;//g
kleur[i][3] = b;//b
}
setkleuren();
}
unsigned int Color(byte r, byte g, byte b) // maakt een getal van de r b en g waardes (hoort bij de ledstrip)
{
//Take the lowest 5 bits of each value and append them end to end
return( ((unsigned int)g & 0x1F )<<10 | ((unsigned int)b & 0x1F)<<5 | (unsigned int)r & 0x1F);
}
Step 6: Creating You Own Animations
i made this program to create animations.
it is not the clearest program ever, but it works.
-it stores .txt files on you computer. you can with the right 'save' part save them as an .AN file on you sd card(your adruino will read them as animations).
-you have to run the porgram as administrator and select a directonary to save the files to function proper.
-the program makes animations of max 100 frames("#a#.TXT"-->these you can open with my program and save as -->) with a maximum of 50 animations("#an.AN"-->these are going to the sd).
-you can select 2 main colors the first comes the first time you click a pixel, the second the second time. you can also select for colors that appear if you clich a pixel and then the '1''2''3'or'4' key on your keyboard
-you can co forward/backward with the QWE buttons in the progam/on you keybaord, the E will kopy this fram to the next frame(only if there is no next fram it doesnt overwirte anything)
-you can set collums and rows at once.
-you can set the time one frame lasts with the time textbox.
-you can set/toggle all pixels at once
-if you want to delete a frame, you can just delete it's .txt file
-the .txt files are saved in a location you have to choose/create. the name is "[animation number]a[frame number].txt"
the save part of my program saves them to the sd card with the name : "[animation nuber]an.AN", you can create animations with a maximum of 100 animations and almostly infinitly frames.
if you have questions about my program (it has some bugs i can't get out of it :( ) you can always ask. also feel free to mod again or send me improvements if you want.
it is not the clearest program ever, but it works.
-it stores .txt files on you computer. you can with the right 'save' part save them as an .AN file on you sd card(your adruino will read them as animations).
-you have to run the porgram as administrator and select a directonary to save the files to function proper.
-the program makes animations of max 100 frames("#a#.TXT"-->these you can open with my program and save as -->) with a maximum of 50 animations("#an.AN"-->these are going to the sd).
-you can select 2 main colors the first comes the first time you click a pixel, the second the second time. you can also select for colors that appear if you clich a pixel and then the '1''2''3'or'4' key on your keyboard
-you can co forward/backward with the QWE buttons in the progam/on you keybaord, the E will kopy this fram to the next frame(only if there is no next fram it doesnt overwirte anything)
-you can set collums and rows at once.
-you can set the time one frame lasts with the time textbox.
-you can set/toggle all pixels at once
-if you want to delete a frame, you can just delete it's .txt file
-the .txt files are saved in a location you have to choose/create. the name is "[animation number]a[frame number].txt"
the save part of my program saves them to the sd card with the name : "[animation nuber]an.AN", you can create animations with a maximum of 100 animations and almostly infinitly frames.
if you have questions about my program (it has some bugs i can't get out of it :( ) you can always ask. also feel free to mod again or send me improvements if you want.
Step 7: End
well, i hope you enjoyed it.
evrybody feel free to hack and mod, and to post pictures if you made it or earlyer made something equal ;)
other ideas:
make it into a t-shirt(i'm working on that)
give it beat detection(also working on that, you will see it in my code)
let it be network controlled
ir remote control
put into a table
sotiri/goedenvraag
my site(still under construction)
youtube
troubleshooting:
it can't read the files on the sd:
try reformatting the sd as FAT, are there .AN file on the sd?
the led's are showing random colors
are they plugged in right in the arduino, and on the BEGINNING of the led strip
pir sensor is not working
some pir senors have diffident output voltage, so you may have to edit the code
evrybody feel free to hack and mod, and to post pictures if you made it or earlyer made something equal ;)
other ideas:
make it into a t-shirt(i'm working on that)
give it beat detection(also working on that, you will see it in my code)
let it be network controlled
ir remote control
put into a table
sotiri/goedenvraag
my site(still under construction)
youtube
troubleshooting:
it can't read the files on the sd:
try reformatting the sd as FAT, are there .AN file on the sd?
the led's are showing random colors
are they plugged in right in the arduino, and on the BEGINNING of the led strip
pir sensor is not working
some pir senors have diffident output voltage, so you may have to edit the code
No comments:
Post a Comment