A three colour LED show

I happened to come across some two-colour LEDs the other day and put them together into this little project. Each LED contains separate red and green LEDs, allowing three colours, because when both are lit a peculiar orange effect is produced. The layout is very simple. The eight cathodes are connected to the eight output ports of the Velleman board. The anodes of the two groups are connected together and driven  - via a BFY52 transistor - by the two DAC of the board. This arrangement allows three colours to be selected and it also permits the brightness of output to be regulated.

Below is the circuit diagram and a suggested PCB layout.

The project


The circuit diagram
The pcb layout

The program

The program is written in the form of a short demo, which runs through various colour   patterns and finishes with a slow fade-out. The LED to be lit is selected with the  statement:

SYS K8055_SetDigitalChannel%,O%(J%)

Where O% is an array that holds the place value of the LED. This is needed because the LEDs are not connected in the right sequence. The different colours are selected by the statement:

SYS K8055_OutputAnalogChannel%,N%,I%

N% is the channel number. When this is 1, the red LED is selected, when it is 2, the green LED lights up. To get the orange colour, both LEDs must be lit: Like this:

SYS K8055_OutputAnalogChannel%,1,I%

SYS K8055_OutputAnalogChannel%,2,I%

I% is a number between 0 and 255 which selects the output voltage of the DAC - 255=5V. To fade the LEDs this number can be slowly changed from 255 to a lower value. Like this:

 FOR J%=255 TO 180 STEP-1
  SYS K8055_OutputAnalogChannel%,2,J%
  TIME=0:REPEAT UNTIL TIME>5
  NEXT

As usual I supply a zip archive with the BBC BASIC for Windows program file and a stand-alone exec file

K8055_LED-3col.zip

There is also a

YouTube video of the project

And here are the two  files for the K8061

K8061_LED-3col.zip


  10 REM LED-Tricolour
   20 REM Drive 8 2-colour LEDs with the K8055
   30 REM (c) Jochen Lueg
   40 REM
   50 REM Limavady, January 2012
   60 REM Vers 1.0
   70
   80 COLOUR 128
   90 CLS
  100 COLOUR 15
  110 ON ERROR PRINT REPORT$;" at line ";ERL  : END
  120 PROCK8055_init   :REM Setup all system calls
  130 PROCinit
  140 SYS K8055_OpenDevice%,Board%
  150 PROCsay_hello
  160 PRINT "Here we go"
  170
  180 PROCturn_right
  190 PROCswap
  200 PROCsay_hello
  210 PROCfadeout
  220 SYS K8055_ClearAllDigital%
  230 SYS K8055_ClearAllAnalog%
  240 SYS K8055_CloseDevice%
  250 END
  260
  270
  280 DEFPROCturn_right
  290 SYS K8055_ClearAllDigital%
  300 SYS K8055_ClearAllAnalog%
  310
  320 SYS K8055_OutputAnalogChannel%,2,255
  330 FOR I%=1 TO 3
  340   FOR J%=1 TO 8
  350     SYS K8055_SetDigitalChannel%,O%(J%)
  360     SYS K8055_SetDigitalChannel%,O%(J%+1)
  370     TIME=0:REPEAT UNTIL TIME>Delay%
  380     SYS K8055_ClearDigitalChannel%,O%(J%)
  390     SYS K8055_ClearDigitalChannel%,O%(J%+1)
  400   NEXT
  410 NEXT
  420
  430 SYS K8055_ClearAllAnalog%
  440 SYS K8055_OutputAnalogChannel%,1,255
  450 FOR I%=1 TO 3
  460   FOR J%=1 TO 8
  470     SYS K8055_SetDigitalChannel%,O%(J%)
  480     SYS K8055_SetDigitalChannel%,O%(J%+1)
  490     TIME=0:REPEAT UNTIL TIME>Delay%
  500     SYS K8055_ClearDigitalChannel%,O%(J%)
  510     SYS K8055_ClearDigitalChannel%,O%(J%+1)
  520   NEXT
  530 NEXT
  540 SYS K8055_ClearAllAnalog%
  550 SYS K8055_OutputAnalogChannel%,1,255
  560 SYS K8055_OutputAnalogChannel%,2,255
  570
  580 FOR I%=1 TO 3
  590   FOR J%=1 TO 8
  600     SYS K8055_SetDigitalChannel%,O%(J%)
  610     SYS K8055_SetDigitalChannel%,O%(J%+1)
  620     TIME=0:REPEAT UNTIL TIME>Delay%
  630     SYS K8055_ClearDigitalChannel%,O%(J%)
  640     SYS K8055_ClearDigitalChannel%,O%(J%+1)
  650   NEXT
  660 NEXT
  670
  680 SYS K8055_ClearAllAnalog%
  690 SYS K8055_OutputAnalogChannel%,1,255
  700 SYS K8055_OutputAnalogChannel%,2,255
  710 FOR I%=1 TO 3
  720   FOR J%=8 TO 1 STEP-1
  730     SYS K8055_SetDigitalChannel%,O%(J%)
  740     SYS K8055_SetDigitalChannel%,O%(J%+1)
  750     TIME=0:REPEAT UNTIL TIME>Delay%
  760     SYS K8055_ClearDigitalChannel%,O%(J%)
  770     SYS K8055_ClearDigitalChannel%,O%(J%+1)
  780   NEXT
  790 NEXT
  800
  810 SYS K8055_ClearAllAnalog%
  820 SYS K8055_OutputAnalogChannel%,1,255
  830 FOR I%=1 TO 3
  840   FOR J%=8 TO 1 STEP -1
  850     SYS K8055_SetDigitalChannel%,O%(J%)
  860     SYS K8055_SetDigitalChannel%,O%(J%+1)
  870     TIME=0:REPEAT UNTIL TIME>Delay%
  880     SYS K8055_ClearDigitalChannel%,O%(J%)
  890     SYS K8055_ClearDigitalChannel%,O%(J%+1)
  900   NEXT
  910 NEXT
  920
  930 SYS K8055_ClearAllAnalog%
  940 SYS K8055_OutputAnalogChannel%,2,255
  950 FOR I%=1 TO 3
  960   FOR J%=8 TO 1 STEP-1
  970     SYS K8055_SetDigitalChannel%,O%(J%)
  980     SYS K8055_SetDigitalChannel%,O%(J%+1)
  990     TIME=0:REPEAT UNTIL TIME>Delay%
 1000     SYS K8055_ClearDigitalChannel%,O%(J%)
 1010     SYS K8055_ClearDigitalChannel%,O%(J%+1)
 1020   NEXT
 1030 NEXT
 1040 SYS K8055_ClearAllAnalog%
 1050 SYS K8055_ClearAllDigital%
 1060 ENDPROC
 1070
 1080
 1090 DEFPROCsay_hello
 1100 REM LEDs go from dark to bright three times in each colour
 1110
 1120 SYS K8055_ClearAllAnalog%
 1130 FOR J%=1 TO 3
 1140   SYS K8055_WriteAllDigital%,255
 1150   FOR I%=180 TO 255
 1160     SYS K8055_OutputAnalogChannel%,1,I%
 1170     SYS K8055_OutputAnalogChannel%,2,I%
 1180   NEXT
 1190   SYS K8055_ClearAllDigital%
 1200   SYS K8055_ClearAllAnalog%
 1210 NEXT



 1220
 1230 FOR J%=1 TO 3
 1240   SYS K8055_WriteAllDigital%,255
 1250   FOR I%=100 TO 255
 1260     SYS K8055_OutputAnalogChannel%,2,I%
 1270   NEXT
 1280   SYS K8055_ClearAllDigital%
 1290   SYS K8055_ClearAllAnalog%
 1300 NEXT
 1310
 1320 FOR J%=1 TO 3
 1330   SYS K8055_WriteAllDigital%,255
 1340   FOR I%=100 TO 255
 1350     SYS K8055_OutputAnalogChannel%,1,I%
 1360   NEXT
 1370   SYS K8055_ClearAllDigital%
 1380   SYS K8055_ClearAllAnalog%
 1390 NEXT
 1400 ENDPROC
 1410
 1420
 1430 DEFPROCfadeout
 1440 SYS K8055_OutputAnalogChannel%,2,255
 1450 FOR J%=1 TO 8
 1460   SYS K8055_SetDigitalChannel%,O%(J%)
 1470   TIME=0:REPEAT UNTIL TIME>Delay%
 1480 NEXT
 1490 FOR J%=255 TO 180 STEP-1
 1500   SYS K8055_OutputAnalogChannel%,2,J%
 1510   TIME=0:REPEAT UNTIL TIME>5
 1520 NEXT
 1530 PRINT"The END"
 1540 SYS K8055_ClearAllDigital%
 1550 SYS K8055_ClearAllAnalog%
 1560 ENDPROC
 1570
 1580
 1590 DEFPROCswap
 1600 FOR I%=1 TO 4
 1610   FOR J%=1 TO 8
 1620     IF J%=1 OR J%=4 OR J%=7 SYS K8055_OutputAnalogChannel%,1,255
 1630     IF J%=2 OR J%=5 OR J%=8 SYS K8055_OutputAnalogChannel%,2,255
 1640     IF J%=3 OR J%=6  SYS K8055_OutputAnalogChannel%,1,255: SYS K8055_OutputAnalogChannel%,2,255
 1650     SYS K8055_SetDigitalChannel%,O%(J%)
 1660     TIME = 0: REPEAT UNTIL TIME >Delay%*2
 1670     SYS K8055_ClearAllDigital%
 1680     SYS K8055_ClearAllAnalog%
 1690   NEXT
 1700 NEXT
 1710 ENDPROC
 1720
 1730
 1740 DEFPROCinit
 1750 Board%=0
 1760 Delay%=7
 1770
 1780 DIM O%(9)
 1790 O%(1)=1
 1800 O%(2)=2
 1810 O%(3)=3
 1820 O%(4)=4
 1830 O%(5)=5
 1840 O%(6)=6
 1850 O%(7)=8
 1860 O%(8)=7
 1870 O%(9)=1
 1880
 1890 DIM T%(8)
 1900 T%(1)=3
 1910 T%(2)=2
 1920 T%(3)=1
 1930 T%(4)=8
 1940 T%(5)=7
 1950 T%(6)=6
 1960 T%(7)=5
 1970 T%(8)=4
 1980
 1990 DIM S%(9)
 2000 S%(1)= 3
 2010 S%(2)= 4
 2020 S%(3)= 5
 2030 S%(4)= 6
 2040 S%(5)= 3
 2050 S%(6)= 2
 2060 S%(7)= 1
 2070 S%(8)= 8
 2080 S%(9)= 7
 2090
 2100 ENDPROC
 2110
 2120
 2130 DEFPROCK8055_init
 2140 REM  Typing errors in routine name do not generate an error message - they just hang up the program.
 2150 SYS"LoadLibrary","K8055D.dll" TO K8055_Board%
 2160 SYS"GetProcAddress",K8055_Board%,"OpenDevice" TO K8055_OpenDevice%
 2170 SYS"GetProcAddress",K8055_Board%,"ReadAnalogChannel" TO K8055_ReadAnalogue%
 2180 SYS"GetProcAddress",K8055_Board%,"SetAllDigital"  TO K8055_SetAllDigital%
 2190 SYS"GetProcAddress",K8055_Board%,"CloseDevice" TO K8055_CloseDevice%
 2200 SYS"GetProcAddress",K8055_Board%,"ClearAllDigital" TO K8055_ClearAllDigital%
 2210 SYS"GetProcAddress",K8055_Board%,"ClearDigitalChannel" TO K8055_ClearDigitalChannel%
 2220 SYS"GetProcAddress",K8055_Board%,"SetDigitalChannel" TO K8055_SetDigitalChannel%
 2230 SYS"GetProcAddress",K8055_Board%,"OutputAnalogChannel" TO K8055_OutputAnalogChannel%
 2240 SYS"GetProcAddress",K8055_Board%,"ClearAnalogChannel" TO K8055_ClearAnalogChannel%
 2250 SYS"GetProcAddress",K8055_Board%,"ClearAllAnalog" TO K8055_ClearAllAnalog%
 2260 SYS"GetProcAddress",K8055_Board%,"WriteAllDigital" TO K8055_WriteAllDigital%
 2270 ENDPROC




Return to the interfacing index


Back to the Limavady home page

Tudor with sign