Go Down

Topic: HELP :  arduino direct to led matrix 5X11 (Read 555 times) previous topic - next topic

ck6

- arduino USB

- LED matrix  5(lignes) X 11(colones)
- logiciel Arduino-11


les LEDs sont touts allumé, ne fait pas passer les mots


ou est le problem?




Code: [Select]



#include <FrequencyTimer2.h>

#define SPACE { \
   {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},  \
   {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \
   {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \
   {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \
   {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \
}

#define H { \
   {0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0}, \
   {0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0}, \
   {0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0}, \
   {0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0}, \
   {0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0}, \
}

#define E  { \
   {0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0}, \
   {0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0}, \
   {0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0}, \
   {0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0}, \
   {0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0}, \
}

#define L { \
   {0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0}, \
   {0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0}, \
   {0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0}, \
   {0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0}, \
   {0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0}  \
}

#define O { \
   {0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0}, \
   {0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0}, \
   {0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0}, \
   {0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0}, \
   {0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0}, \
}

byte col = 0;
byte leds[5][11];

// pin[xx] on led matrix connected to nn on Arduino (-1 is dummy to make array start at pos 1)
int pins[17]= {-1, 5, 4, 3, 2, 14, 15, 16, 17, 13, 12, 11, 10, 9, 8, 7, 6};

// col[xx] of leds = pin yy on led matrix
int cols[11] = {pins[13], pins[3], pins[4], pins[10], pins[06], pins[11], pins[15], pins[16],  pins[7], pins[2], pins[5]};

// row[xx] of leds = pin yy on led matrix
int rows[5] = {pins[9], pins[14], pins[8], pins[12], pins[1]};

const int numPatterns = 6;
byte patterns[numPatterns][5][11] = {
 H,E,L,L,O,SPACE
};

int pattern = 0;

void setup() {
 // sets the pins as output
 for (int i = 1; i <= 16; i++) {
   pinMode(pins[i], OUTPUT);
 }

 // set up cols and rows
 for (int i = 1; i <= 5; i++) {
   digitalWrite(cols[i - 1], LOW);
 }

 for (int i = 1; i <= 11; i++) {
   digitalWrite(rows[i - 1], LOW);
 }

 clearLeds();

 // Turn off toggling of pin 11
 FrequencyTimer2::disable();
 // Set refresh rate (interrupt timeout period)
 FrequencyTimer2::setPeriod(2000);
 // Set interrupt routine to be called
 FrequencyTimer2::setOnOverflow(display);

 setPattern(pattern);
}

void loop() {
   pattern = ++pattern % numPatterns;
   slidePattern(pattern, 60);
}

void clearLeds() {
 // Clear display array
 for (int i = 0; i < 5; i++) {
   for (int j = 0; j < 11; j++) {
     leds[i][j] = 0;
   }
 }
}

void setPattern(int pattern) {
 for (int i = 0; i < 5; i++) {
   for (int j = 0; j < 11; j++) {
     leds[i][j] = patterns[pattern][i][j];
   }
 }
}

void slidePattern(int pattern, int del) {
 for (int l = 0; l < 5; l++) {
   for (int i = 0; i < 4; i++) {
     for (int j = 0; j < 11; j++) {
       leds[j][i] = leds[j][i+1];
     }
   }
   for (int j = 0; j < 11; j++) {
     leds[j][4] = patterns[pattern][j][0 + l];
   }
   delay(del);
 }
}

// Interrupt routine
void display() {
 digitalWrite(cols[col], LOW);  // Turn whole previous column off
 col++;
 if (col == 11) {
   col = 0;
 }
 for (int row = 0; row < 5; row++) {
   if (leds[col][4 - row] == 1) {
     digitalWrite(rows[row], LOW);  // Turn on this led
   }
   else {
     digitalWrite(rows[row], HIGH); // Turn off this led
   }
 }
 digitalWrite(cols[col], HIGH); // Turn whole column on at once (for equal lighting times)
 delayMicroseconds(900);  // Delay so that on times are longer than off time = brighter leds
}


mrbbp

et comment tu allumes / éteinds tes leds ? 8-)

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy