Making progress on 8x8 LED matrix. How do I write an entire line?

1 post / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm using the following code to get the attached picture. Is there an easier way to toggle rows off in a colum? I'm ultimately going to try to display a heart. 

 

#include <avr/io.h>
#include <util/delay.h>
 
#define BLINK_DELAY_MS 1000
 
int main (void)
{
 //rows
 DDRB |= _BV(DDB5);		/* set pin 5 of PORTB for output*/
 DDRB |= _BV(DDB3);   		/* set pin 3 of PORTB for output arduino pin 11*/  
 DDRD |= _BV(DDD6);		/* set pin 6 of PORTD for output  arduino pin 6*/
 DDRB |= _BV(DDB2);		/* set pin 2 of PORTB for output  arduino pin 10*/ 	
 DDRD |= _BV(DDD3);		/* set pin 3 of PORTD for output arduino pin 3*/
 DDRC |= _BV(DDC3);		/* set pin 3 of portC for output arduino pin A3*/
 DDRD |= _BV(DDD4);		/* set pin 4 of PORTD for output arduino pin 4*/ 
 DDRB |= _BV(DDB0);   		/* set pin 0 of PORTB for output arduino pin 8*/
 DDRB |= _BV(DDB1);   		/* set pin 1 of PORTB for output arduino pin 9*/    

 //columns
 DDRD |= _BV(DDD2);  		
 DDRD |= _BV(DDD7);
 DDRC |= _BV(DDC5);
 DDRD |= _BV(DDD5);
 DDRB |= _BV(DDB5);
 DDRC |= _BV(DDC4);
 DDRB |= _BV(DDB4);
 DDRC |= _BV(DDC2);

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);
  PORTD |= _BV(PORTD7);
  PORTC |= _BV(PORTC5);
  PORTD |= _BV(PORTD5);
  PORTB |= _BV(PORTB5);
  PORTC |= _BV(PORTC4);
  PORTB |= _BV(PORTB4);
  PORTC |= _BV(PORTC2);

  

/* set pin 5 low to turn led off */
  PORTB &= ~_BV(PORTB5);
  //_delay_ms(BLINK_DELAY_MS);

  PORTB &= ~_BV(PORTB3);
  //_delay_ms(BLINK_DELAY_MS);

  PORTD &= ~_BV(PORTD6);
  //_delay_ms(BLINK_DELAY_MS);

  PORTB &= ~_BV(PORTB2);
  //_delay_ms(BLINK_DELAY_MS);

  PORTD &= ~_BV(PORTD3);
  //_delay_ms(BLINK_DELAY_MS);

 

Attachment(s): 

Last Edited: Sat. Aug 1, 2015 - 09:26 PM