Last edited by ScaleRobotics; - 13th July 2010 at 23:48.
I think this page explains what Walter is doing pretty well ...
http://www.batsocks.co.uk/readme/p_tut_led16.htm
DT
Simplest coding would be to generate a square wave signal on the pin, and then set the TRIS based on state of each LED. TRIS would have to be set every time you change the state of the pin in the square wave generating code. That way the LEDs will always be the same brightness. Of course the square wave signal would have to be interrupt driven off of a timer in order to have both LEDs on at the same time.
Tim Barr
Last edited by sayzer; - 16th July 2010 at 13:24. Reason: typo
"If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte
Yes, the four states can be obtaind with only one pin. Very nice!
Now, if you use the red-green LED that I mentioned above a cool project can be made.
http://futurlec.com/LED/LED3RG.shtml
Since red + green = yellow, then with only one pin in the MCU we can obtain four different states in the LED: off, red, green, or yellow. Also, by varying the percentage duty cycle of the square wave different shades of yellow can be obtained. I haven't tried this yet but it might be a cool project.
Robert
RED and BLUE = ON
The only way I can think of is to connect them in parallel. (if serial, 3.3V will not go through)
![]()
"If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte
Last edited by rsocor01; - 17th July 2010 at 13:51.
Hey Robert,
Can you give some example code for how the square wave method would work?
Say you have something like the sliding door app.
Green = full open
Red = closed
OFF = inbetween
Yellow = moving
Dave
Always wear safety glasses while programming.
Bookmarks