Loading...
Pages: [1]   Go Down
Author Topic: Embedded Adventures 64x16 Matrix  (Read 629 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi All,
I'm attempting to get my new led matrix to work with my arduino.  Has anyone got this particular matrix working?
http://www.embeddedadventures.com/LED_matrix_display_LDP-6416.html
I know how it works, but I'm having trouble looping through the rows.  To select a row I need to set pins A, B, C and D to match the row number in binary. IE: row 1 would be D = 0, C = 0, B = 0, A = 1, row 2 would be D = 0, C = 0, B = 1, A = 0 .... row 16 would have all pins set to 1.  How would I do this in an elegant way?  I would rather not write out this code for each row if I can help it.
Code:
  digitalWrite(en,HIGH);
  digitalWrite(pinA, LOW);
  digitalWrite(pinB, LOW);
  digitalWrite(pinC, LOW);
  digitalWrite(pinD, LOW);
  digitalWrite(l,HIGH);
  digitalWrite(l,LOW);
  digitalWrite(en,LOW);
Im sure there is a super easy way to do this but I'm not experienced enough with the arduino platform to think of a way.  Also would this be easier to implement if I skipped writing it in the arduino IDE and went straight to programming it in C?
Thanks
Mark
Logged

Southern California
Offline Offline
Sr. Member
****
Karma: 5
Posts: 466
I like blinky lights
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Put the row select lines on consecutive register pins, for example D4-D7. Then use the PORT command to write all the pins at once, directly, with your value. Here's some pseudocode:

Code:
void SetRow(int row) {
   PORTD = (PORTD&15) || (row<<4);
   }

You'll need to understand direct port manipulation:

http://www.arduino.cc/en/Reference/PortManipulation

but since you say "straight to programming in C" I'll bet you'll get it in no time.

Good luck!
Logged

http://en.wiktionary.org/wiki/magagna <-- My last name.  Pretty apt.

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thats exactly what I'm looking for!  Just one question though, I cant wrap my head around (PORTD&15) || (row<<4);   Is that code supposed to actually work? Or am I right in thinking that this is a boolean statement.  Either way I have an answer to my original question.
Thanks again!
Logged

Southern California
Offline Offline
Sr. Member
****
Karma: 5
Posts: 466
I like blinky lights
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm an idiot... The statement should have one '|' for logical OR, not two for boolean.

(PORTD&15) | (row<<4).

You want to read PORTD, save the lower 4 bits (so you don't change D0 - D3 when you're updating D4-D7); shift row 4 bits (so it will go into D4-D7), or them together.

Chris


Logged

http://en.wiktionary.org/wiki/magagna <-- My last name.  Pretty apt.

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I kind of thought thats what you meant, but I was thinking it was some special code related to port manipulation.  I didnt even think about saving the lower bits, makes sense.
Logged

Pages: [1]   Go Up
Print
 
Jump to: