Go Down

Topic: LED DOT MATRIX 64x16 (Read 60907 times) previous topic - next topic

Dancopy

#90
May 26, 2019, 12:33 am Last Edit: May 26, 2019, 12:38 am by Dancopy
Greetings to all!
I am not a programmer, I am far from it, but I am simply an admirer, especially of these colored LED panels and, I would like your opinion on which LED array module should I buy, to do, among other things, a Clock and/or Static or Dynamic Scrolling Text, in two lines or not, considering the ease of finding Arduino sketches for this.
These are two preferred options:

1) https://pt.aliexpress.com/item/32977781030.html?spm=a2g0o.cart.99999999.258.17053c00AzXLXx

2) https://www.ebay.com/itm/LED-Lattice-Module-16x24-Dot-Matrix-LED-Subtitle-Text-Display-Program-3-3V-5V/372659863414

Option (1) would be a two-color panel (64x16), and option (2) would be two panels (16x24 x2 = 16x48), considering its smaller size;
In short, what better panel, if I may say so?
Thanks to anyone who can help me.

taipscode

 Hello everybody.

i don't know how to use array pointer ,can you help me !

i downloaded shortened_Final_Code_A.ino , it works good .
But i don't understand these code ,can you explan for me .
Thankyou

for (byte i=0; i<fontrows; i++) {
       *pDst = *pSrc;     // populate the destination byte
       pDst += 8;         // go to next row on buffer
       pSrc++;            // go to next set of 8 pixels in character
   }

-------------------------------------



and full codes:
// Arduino 1.0.5 UNO R3


// Connections to board
const byte latchPin=8;
const byte clockPin=12;
const byte data_R1=10;
const byte data_R2=11;
const byte en_74138=2;
const byte la_74138=3;
const byte lb_74138=4;
const byte lc_74138=5;
const byte ld_74138=6;
byte ScanRow = 0;
unsigned long counter;

//Insert message here ("message ")
const char message[] = "Tustin High School T-Tech Academy     ";



// Routine to print a single character in one of 8 columns
// Inputs:
// x is one of (0,16,24,32,40,48,56),
// y (0 to 16 or 24 depending upon font size),
// n is either (0 to 9) or an ascii value,
// font=0 for big font, 2 for small font,
// inverse is true for an inverted character
void drawChar(uint16_t x, uint16_t y, byte n, byte font, boolean inverse) {
   byte charbytes[16], fontrows, xover8 = x>>3;
   int index;
   if (0 != (x % 8)) return;    // x not a multiple of 8
   if ((n>9) && (n<32)) return; // invalid character
   if (font==0) fontrows=16; else fontrows=8;
   if ((n>=0) && (n<=9)) index=(n+16)*fontrows; else index=(n-32)*fontrows; // go to the right code for this character

// addressing start at buffer and add y (rows) * (WIDTH is 64 so WIDTH/8) is 8 plus (x / 8) is 0 to 7
   byte *pDst = buffer + (y << 3) + xover8;
   for (byte i=0;i<fontrows;i++) {  // fill up the charbytes array with the right bits
     if (font==0) charbytes = pgm_read_byte(&(font8x16_basic[index+i]));
     // reverse bit order for fonts 0 and 1
     if (font != 0) {
       charbytes = (charbytes & 0xF0) >> 4 | (charbytes & 0x0F) << 4;
       charbytes = (charbytes & 0xCC) >> 2 | (charbytes & 0x33) << 2;
       charbytes = (charbytes & 0xAA) >> 1 | (charbytes & 0x55) << 1;
     };
     if (inverse) charbytes = ~charbytes;
     };
   const byte *pSrc = charbytes; // point at the first set of 8 pixels    
   for (byte i=0; i<fontrows; i++) {
       *pDst = *pSrc;     // populate the destination byte
       pDst += 8;         // go to next row on buffer
       pSrc++;            // go to next set of 8 pixels in character
   }
};

void moveLeft(byte pixels, byte rowstart, byte rowstop) { // routine to move certain rows on the screen "pixels" pixels to the left
byte row, column;
short unsigned int address;
 for (column=0;column<8;column++) {
   for (row=rowstart;row<rowstop;row++) {
     address = (row<<3) + column; /// right here!
     if (column==7)
        buffer[address] = buffer[address]<<pixels; // shuffle pixels left on last column and fill with a blank
       else {                // shuffle pixels left and add leftmost pixels from next column
        byte incomingchar = buffer[address+1];
        buffer[address] = buffer[address]<<pixels;
        for (byte x=0;x<pixels;x++) { buffer[address] += ((incomingchar & (128>>x)) >> (7-x))<<(pixels-x-1); };
        }
    }
 }
};



void shiftOut(byte row) { // fast routine to shove out 8 columns into two rows via board's shift registers
 for(byte column=0;column<8;column++) {
   byte index = column + (row<<3);  
   for(byte i=0;i<8;i++) {    
     PORTB &=~(3<<(data_R1-8));                                 // data_R2 is LOW; data_R1 is LOW;
     PORTB &=~(1<<(clockPin-8));                                // digitalWrite(clockPin,LOW);
     PORTB |= !((buffer[index]>>(7-i)) & 0x01) << (data_R1-8);  // top set of rows
     PORTB |= !((buffer[index+128]>>(7-i)) & 0x01) << (data_R2-8); // bottom set of rows
     PORTB |= 1<<(clockPin-8);                                  // digitalWrite(clockPin,HIGH);
   };
 };
};

ISR(TIMER2_COMPA_vect){  
    cli();
    digitalWrite(en_74138, HIGH);     // Turn off display
    shiftOut(ScanRow);                // Shift out 8 columns
    digitalWrite(latchPin, LOW);
    digitalWrite(latchPin, HIGH);
    PORTD = (ScanRow << 3) | (PORTD & 0X87); // Highlight row: pins 3 4 5 6 (la_74138 lb_74138 lc_74138 ld_74138)
    digitalWrite(en_74138, LOW);     // Turn on display
    ScanRow++;                       // Do the next pair of rows next time this routine is called
    if (ScanRow==16) ScanRow=0;
    sei();
};

void setup() {

// Set up Timer2 as the scanning interrupt timer
 cli(); // clear interrupts
 TCCR2A = 0; TCCR2B = 0; TCNT2  = 0;
 TCCR2B |= (1 << CS12) | (1 << CS10);     // Set 1024 prescaler
              // 160Hz scan rate = 10 frames/second (16 pairs of rows)
 OCR2A = 97;  // 97 = (16,000,000 / (1024*160)) - 1
 TCCR2A |= (1 << WGM21); TIMSK2 |= (1 << OCIE2A);
 
 pinMode(latchPin,OUTPUT);  pinMode(clockPin,OUTPUT);
 pinMode(data_R1,OUTPUT);   pinMode(data_R2,OUTPUT);
   
 pinMode(en_74138,OUTPUT);
 pinMode(la_74138,OUTPUT);  pinMode(lb_74138,OUTPUT);
 pinMode(lc_74138,OUTPUT);  pinMode(ld_74138,OUTPUT);
 
 digitalWrite(en_74138, LOW);
 digitalWrite(data_R1, HIGH); digitalWrite(data_R2, HIGH);
 counter = millis();
 sei(); //allow interrupts
};

void loop() {  
static int count=0;




   
// display next character of message
   drawChar(56,16,message[count%(sizeof(message)-1)],0,false);
   count = (count + 1);
   // move the text 7 pixels (not 8 because it looks better) to the left
   for (byte i=0; i<4; i++) {
      delay(80);
      moveLeft(2,1,32);
   };
};



Dancopy

@taipscode
Sorry, after so long, what you do not understand in this sketch? It is simply to scroll a configurable text message on the line: const char message [] = "Tustin High School T-Tech Academy";

Go Up