Newbee project
alfa88
Posts: 5
I just finished the Boe-Bot and decided to tear off the Basic Stamp board to drive a 6X6 led matrix. I am real beginner at programming so I hope someone will hold my hands so to speak. What I have done is use P0 through P11 as outputs. P0 through P5 are the X axis and P6 through P11 are the Y axis. The program I wrote simply addresses each led with the high/low commands. I then replicated the same code 10 times and changed the pause each time to speed up the scan. I am hoping there is a better way to do this because I used up the RAM in a hurry with my simpleton program.
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Think Inside the box first and if that doesn't work..
Re-arrange what's inside the box then...
Think outside the BOX!
'1st scan
HIGH 0
LOW 6
HIGH 7
HIGH 8
HIGH 9
HIGH 10
HIGH 11
PAUSE 125
LOW 0
HIGH 1
PAUSE 125
LOW 1
HIGH 2
PAUSE 125
LOW 2
HIGH 3
PAUSE 125
LOW 3
HIGH 4
PAUSE 125
LOW 4
HIGH 5
PAUSE 125
LOW 5
I'm glad that the Boe-Bot has inspired you to start buiding your own projects!· For an example of efficiently turning on and off groups of I/O pins in patterns with a single command, take a look at Chapter 6 of "What's a Microcontroller?" - it's about controlling a 7-segment LED, but it's an easy introduction to using OUTH, DIRH, etc.
You can download the book (and many others) free from this page:
http://www.parallax.com/tabid/535/Default.aspx
Have fun!
-Stephanie Lindsay
Editor, Parallax Inc.
Reduced to 5 lines in a for next loop
The 6th line is a debug output to show the state of the pins (can be removed)
There is one logic difference in that pin 6 is set HIGH on exit of the code, one additional line to turn bit 5 off after the loop and reducing the loop count by 1 would be more exact. If bit 6 was not used then it would not matter.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Think Inside the box first and if that doesn't work..
Re-arrange what's inside the box then...
Think outside the BOX!
Thank's for your help. I'll play with it. Just as a graphical aid I made a pictorial of what I'm doing.
---- Anodes----
J0 J1 J2 J3 J4 J5
J6 O O O O O O
J7 O O O O O O
J8 O O O O O O
J9 O O O O O O
J10 O O O O O O
J11 O O O O O O
Post Edited (alfa88) : 8/15/2008 5:37:38 AM GMT
The code:
' improved 6x6 led scanner program
' {$STAMP BS2}
' {$PBASIC 2.5}
x CON %100000011111
x1 CON %010000011111
x2 CON %001000011111
x3 CON %000100011111
x4 CON %000010011111
x5 CON %000001011111
x6 CON %100000101111
x7 CON %010000101111
x8 CON %001000101111
x9 CON %000100101111
x10 CON %000010101111
x11 CON %000001101111
x12 CON %100000110111
x13 CON %010000110111
x14 CON %001000110111
x15 CON %000100110111
x16 CON %000010110111
x17 CON %000001110111
x18 CON %100000111011
x19 CON %010000111011
x20 CON %001000111011
x21 CON %000100111011
x22 CON %000010111011
x23 CON %000001111011
x24 CON %100000111101
x25 CON %010000111101
x26 CON %001000111101
x27 CON %000100111101
x28 CON %000010111101
x29 CON %000001111101
x30 CON %100000111110
x31 CON %010000111110
x32 CON %001000111110
x33 CON %000100111110
x34 CON %000010111110
x35 CON %000001111110
OUTH = %000000000000
DIRH = %111111111111
index VAR Byte
DO
FOR index = 0 TO 36
LOOKUP index, [noparse][[/noparse] x, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15,
x16, x17, x18, x19, x20, x21, x22, x23, x24, x25, x26, x27, x28, x29, x30, x31, x32, x33, x34, x35 ], OUTH
PAUSE 100
NEXT
LOOP