i had a question on LEDs myself. I was making some LEDs light up individualy. I wanted to know if i can use 2 differnet sub-routines to make 3 LEDs turn on then off. One sub-rotines turns them on while the second turns them off.
Right now i only know how to turn the lights on and off myself, but i need a sub-routine. Any ideas on how the code would look?
Can somebody also give me some information on Lables. I have no idea how they work or how to set them. The book hints that we kinda need to use lables.
Assuming you have three leds on lets say pins P4 P5 and P6 and that the LEDs wired that they turn on when the pin has high voltage. Then you could have something like:
LED1 con P4
LED2 con P5
LED3 con P6
main:
gosub TurnLedsOn
pause 500
gosub TunLedsOff
pause 500
goto main
TurnLedsOn
high LED1
high LED2
high LED3
return
TurnLedsOff
Low LED1
Low LED2
Low LED3
return
Please note, I did not check to make sure this code compiles or the like, but it should give you an idea of labels and how to call simple subroutines with no parameters.
Rather than starting a new thread…
if one wanted the ABB’s LED’s to light up in a sequence would the following work. Red on - red off & green on - green off & yellow on - yellow off. (loop)
RED con P12
GREEN con P13
YELLOW con P14
main:
low RED
pause 500
high RED
low GREEN
pause 500
high GREEN
low YELLOW
pause 500
high YELLOW
pause 500
goto main
also what voltage comes from the ABB’s pins across the board?
thanks.
The LED’s are part of the push button / LED (simple user interface)circuitry. You can light up the LED’s and check the status of the push buttons on one I/O pin. True you can turn the LED on with a low and off with a high, but it’s not a good idea to use a high to turn the LED off. Here’s why.
The push buttons are connected to the I/O pin and then to ground. If you make the pin a high and press the button, even by accident, you can burn out the I/O pin.
The LED and button circuitry works great, but there are only two valid states for the I/O pin! It’s either in input or a low.
Making it an input to check the status of the I/O pin. This is done very briefly just long enough to check the status of the push button. It happens so fast the LED never appears to go out.
Make it a low in order to light up the LED.
In use your program would keep the I/O pin an input. If you need to light up the LED, you make the I/O pin a low. To keep the LED lit and read the status of the I/O pin you need to make the I/O pin an input just prior to checking the status of the pin, then it must be switched back to a low immediately after checking the status of the I/O pin.
So there really is no chance to short the I/O pin if programmed properly.
Last question, the voltage that comes from the ABB’s pins are the same as what comes from the chip installed in it. They are standard CMOS 5vdc or 0vdc high or low, but the Atom Pro has a couple 3.3vdc pins.