Driving LED's With Digital I/O Lines

LED's may be driven by digital I/O lines and require only a current limit resistor to limit current to 20mA or less. Digital I/O lines can source ( LED 1) or sink ( LED2)   LED current. If the I/O line is to sink LED current, the "RESPAn" command is used to turn the LED on and the "SETPAn" command is used to turn the LED off.. If the I/O line is to source LED current, the "SETPAn" command is used to turn the LED on and the "RESPAn" command is used to turn the LED off. The following example shows the use of anADR101 to control two LED's in each of the before mentioned configurations.

LED.gif (16946 bytes)

10 OPEN "COM1:9600,N,8,1,CS,DS,RS" AS#1
20 PRINT#1, "CPA11111100"
30 REM TURN ON LED#1
40 PRINT#1, "SETPA0"
50 REM TURN OFF LED#1
60 PRINT#1, "RESPA0"
70 REM TURN OFF LED#2
80 PRINT#1, "SETPA1"
90 REM TURN ON LED#2
100 PRINT#1, "RESPA1"
110 BEEP
120 GOTO 30          

 Back to Applications Page