OUTH and DIRTH problems
logan996
Posts: 281
I bought a 10 segment LED bar to use to make a test light meter for the TSL230R (light to freq. converter) that i got for $2 at radioshack. I got the 10 segment working on pins 0-9 (with 470 ohm resistors)·and tested them all one by one and then each one plus all the others by using the LOW and HIGH commands, Now i am starting to get ready to make the program to integrate both of them in to my program but i realized that it would take up a lot more code and time to make it all low and high commands (i am planning for all the bars up to the the one being shown to be lit) so i was going to use OUTH and DIRTH commands. I took out my WAM? book and looked over the DisplayDigits.bs2 program in it and the surrounding pages on how it works (pgs. 175 - 178) and then i tried using a 16 bit/digit binary number (ex. OUTH = %0000000000000000) i tried it using the last 2 numbers being 1's (OUTH= 0000000000000011) but it only lit up the top 2 bars (pins 9 and 8) so i experimened even more and i can't find out how to light up pins 0-9 all at once (or like 0-5 0-6 0-4 so on) i need to use outh and dirth because it would be too slow using HIGH and LOW because i am still taking reading from a light sensor nd converting them into a 1-10 number i can display.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"WOAH! that wasn't supposed to happen!"
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"WOAH! that wasn't supposed to happen!"
Comments
OUTH = %00000000
OUTH = %00000001
OUTH = %00000011
OUTH = %00000111
OUTH = %00001111
OUTH = %00011111
OUTH = %00111111
OUTH = %01111111
OUTH = %11111111
To control the other two LEDs, you'd either have to use the other two pins individually (OUT8 and OUT9) or use OUTS to control all 16 pins at once with the same technique. In the latter case, you'd have to be careful not to do something unexpected with other I/O pins that you might be using for other purposes.
If you're just using other I/O pins as inputs, it won't matter that you're changing the corresponding OUTS bits. The OUTS bits don't affect pins set as inputs with DIRS.
To make a "bar" of one bits given a value from 0 to 9, do something like:
bar = (1 << value) - 1
Post Edited (Mike Green) : 6/2/2010 2:56:44 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
·