8x8 LED question regarding loading the ports/pins with hex values

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've discovered that certain pins control certain columns on the matrix. Most of the example programs I've seen have for loop that use something like "displaywrite([column][code])

 

The way I have the code below set up, it is writing to the entire port the hex value. How would I go about getting that hex value onto each column so that it will actually display the image?

 


#include <avr/io.h>
#include <util/delay.h>
 
#define BLINK_DELAY_MS 1000
 
int main (void)
{
	DDRB |= 0xFF;		// everbody output!
	DDRD |= 0xFF;
	DDRC |= 0xff;
	
while(1) {
  /* set pin 5 high to turn led on */
  PORTB |= _BV(PORTB5);
  //PORTB |= _BV(PORTB3);
  //PORTD |= _BV(PORTD6);
  //PORTB |= _BV(PORTB2);
  //PORTD |= _BV(PORTD3);
  //PORTC |= _BV(PORTC3);		/* set pin 3 of portC for output arduino pin A3*/
  //PORTD |= _BV(PORTD4);		/* set pin 4 of PORTD for output arduino pin 4*/
  //PORTB |= _BV(PORTB0);   		/* set pin 0 of PORTB for output arduino pin 8*/
  //PORTB |= _BV(PORTB1);   

  //column
/*  PORTD |= _BV(PORTD2);  //col8
  PORTD |= _BV(PORTD7);  //col7
  PORTC |= _BV(PORTC5);  //col6
  PORTD |= _BV(PORTD5);  //col5
  PORTB |= _BV(PORTB5);  //col4
  PORTC |= _BV(PORTC4);  //col3
  PORTB |= _BV(PORTB4);  //col2
  PORTC |= _BV(PORTC2);  //col1
*/
  PORTD |= _BV(0x00);  //col8
  PORTD |= _BV(0x18);  //col7
  PORTC |= _BV(0x3C);  //col6
  PORTD |= _BV(0x7E);  //col5
  PORTB |= _BV(0xFF);  //col4
  PORTC |= _BV(0xFF);  //col3
  PORTB |= _BV(0x66);  //col2
  PORTC |= _BV(0x00);  //col1




//how to draw heart
//unsigned char row_val[8]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
//unsigned char col_val[8]={0x00,0x66,0xff,0xff,0x7e,0x3c,0x18,0x00};
 }
}

 

Last Edited: Sat. Aug 1, 2015 - 05:12 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Do you realise that

_BV(0x3C)

is nonsense? After the substitution there will be 1<<0x3C and it is far more than int resolution so it is just 0

Anyway, if you have for example whole PORTC as columns with npn transistors and PORTD as rows:

for (uint8_t mask=1, i=0; i<8; ++i,mask<<=1) {
    PORTC = mask;
    PORTD = image[i];
    _delay_ms(2);
    PORTC = 0;
    // delay for full turn off of transistor ?
}

Or even better to have timer interrupt to switch rows and displaying data without _delay_ms()

Computers don't make errors - What they do they do on purpose.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You could have continued with this one or edited this one https://www.avrfreaks.net/forum/m...

Perhaps moderator will lock other one.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

No transistors, just resitsors. 

 

I have it hooked like the attached picture. 

Attachment(s):