Moving a led from 8x8 led matrix

Thread Starter

gabi68

Joined May 4, 2009
8
Hi,

I need a piece of code - in Mikrobasic - to move a led (from a 8x8 led matrix). I will use a pic16F887 and I will try to simulate that in Proteus. Can somebody help me with that.
My setup is:
1- LED-Matrix Row pins to PORTA
2- LED-Matrix Column pins to PORTB 330Ohm resistors.
What I wrote until now is like that
program matrix
'porta - coloana
'portb - linie

dim i as byte

main:
TrisA=0
TrisB=0

while 1

PortA = 0x01
PortB=0x7f
delay_ms 200
PortA = 0x02
PortB=0xbf
delay_ms 200
PortA = 0x04
PortB=0xdf
delay_ms 200
PortA = 0x08
PortB=0xef
delay_ms 200

wend
end.
How I can wrote a procedure to automate this procedure?

Thank you
Gabi
 

John P

Joined Oct 14, 2008
2,026
Move a LED?

A procedure to automate the procedure?

Maybe you could get a friend to help you with the language. The main question is what do you actually want to do?
 

Thread Starter

gabi68

Joined May 4, 2009
8
By moving I mean lit up a led or more by a pattern. I want to see a snippet of code in Mikrobasic which can scroll a series of led's in order to understand how it working. What I wrote in my fisrt message it is a simple pattern which lit up a diagonal of a 8x8 matrix starting from upper left corner.
What I want it is to scroll a pattern to a 8x8 matrix.
I hope now it is aliitle bit clear.

Many thanks
Gabi
 
Last edited:

nerdegutta

Joined Dec 15, 2009
2,684
I think I would have done something like this. See att. And clocked the CD4017 at a fast pace. The LED is blinking, but real fast, so the eye and brain think it is permanent on.
 

Attachments

Thread Starter

gabi68

Joined May 4, 2009
8
Thank you for that, but what I need it is a snippet of code which can do that in mikrobasic if itis possible.

Thank you
Gabi
 

John P

Joined Oct 14, 2008
2,026
I don't know Mikrobasic.

Your LEDs won't be very bright if you use 330 ohm resistors. Remember that each one will be on only 1/8 of the time. Maybe 120 ohms would be about right. Even then, the lights will be rather dim.

It seems as if Port A is the current source, and connects to LED anodes, and Port B is the current sink, and connects to the cathodes via a resistor per 8 LEDs.

What you need to do in this case is have 8 bytes which will be put onto Port B in turn, with a brief delay that keeps you from seeing any flicker; maybe 1KHz, so you get a full scan in 1/125 sec. For each byte on Port B, you set one output pin of Port A high. A given LED will be "on" if the corresponding bit that's sent to Port B is low.

To scroll in one dimension, you would shift the 8-byte array so that each byte goes up or down one position, and a new byte gets added to the end of the array.

To scroll in the other dimension, you would need to rotate each byte in the array left or right, and for each byte, add a new highest or lowest bit to replace the bit which will be lost at the far end of the byte.
 

John P

Joined Oct 14, 2008
2,026
I don't know Mikrobasic.

Your LEDs won't be very bright if you use 330 ohm resistors. Remember that each one will be on only 1/8 of the time. Maybe 120 ohms would be about right. Even then, the lights will be rather dim.

It seems as if Port A is the current source, and connects to LED anodes, and Port B is the current sink, and connects to the cathodes via a resistor per 8 LEDs.

What you need to do in this case is have 8 bytes which will be put onto Port B in turn, with a brief delay that keeps you from seeing any flicker; maybe 1KHz, so you get a full scan in 1/125 sec. For each byte on Port B, you set one output pin of Port A high. A given LED will be "on" if the corresponding bit that's sent to Port B is low.

To scroll in one dimension, you would shift the 8-byte array so that each byte goes up or down one position, and a new byte gets added to the end of the array.

To scroll in the other dimension, you would need to rotate each byte in the array left or right, and for each byte, add a new highest or lowest bit to replace the bit which will be lost at the far end of the byte.

This might be useful to you:
http://www.instructables.com/id/8x8-LED-matrix/
 
Top