' ========================================================================= ' ' File...... HC4LED2.SXB ' Compiler.. SXB Version 1.42.01 ' Purpose... Demonostrate use of HC4LED display module using scrolling text ' Author.... Terry Hitt ' E-mail.... terry@hittconsulting.com ' Started... ' Updated... ' ' ========================================================================= ' ------------------------------------------------------------------------- ' Program Description ' ------------------------------------------------------------------------- ' HC4LED Pinout: ' Pin1 = +5VDC (White wire) ' Pin2 = Gnd ' Pin3 = Blank (Must connect to Gnd to enable display) ' Pin4 = No Connection ' Pin5 = Clock (Connect to RA.0 for this demo program) ' Pin6 = Data (Connect to RA.1 for this demo program) ' ' ' Each segment of the display is addressable, so you can create letters ' and symbols. ' To display custom symbols: ' Set the variables "segments(0)" thru "segments(3)" (segments(0) is on the left) ' simply add the segment values that you want on ' Then use "DisplaySegments" to show the segments on the display ' ' ---4--- ' | | ' 2 8 ' | | ' |---1---| ' | | ' 64 16 ' | | ' --32--- ' ' For example "F" would be 4+2+1+64 = 71 ' ' ------------------------------------------------------------------------- ' Device Settings ' ------------------------------------------------------------------------- DEVICE SX28,OSC4MHZ,TURBO,STACKX,OPTIONX FREQ 4_000_000 ' ------------------------------------------------------------------------- ' IO Pins ' ------------------------------------------------------------------------- Clk VAR RA.0 Dat VAR RA.1 ' ------------------------------------------------------------------------- ' Constants ' ------------------------------------------------------------------------- ' ------------------------------------------------------------------------- ' Variables ' ------------------------------------------------------------------------- segments VAR Byte (4) cnt VAR Byte temp1 VAR Byte message VAR Byte (16) messPos VAR Byte messLen VAR Byte speed VAR Byte ' ========================================================================= PROGRAM Start ' ========================================================================= ' ------------------------------------------------------------------------- ' Subroutine Declarations ' ------------------------------------------------------------------------- DisplayArray SUB LEDOut SUB 1 ' ------------------------------------------------------------------------- ' Program Code ' ------------------------------------------------------------------------- Start: HIGH Clk ' PUT message, 102, 126, 126, 98, 0, 115, 112, 59, 0, 64, 99, 0, 0, 0 ,0 ' COOL buy it ' messLen = 15 ' speed = 50 ' PUT message, 91, 64, 99, 99, 0, 102, 113, 81, 55, 112, 66, 99, 64, 81, 63, 0 ' Hitt Consulting ' messLen = 16 ' speed = 50 ' PUT message, 65, 103, 95, 121, 59 ,0, 0, 0' ready ' messLen = 8 ' speed = 15 PUT message, 119, 65, 103, 103, 81, 65, 95, 59, 0, 0, 0, 0 ' Greenray messLen = 12 speed = 30 messPos = 0 Main: segments(0) = message(messPos) INC messPos IF messPos >= messLen THEN messPos = 0 ENDIF segments(1) = message(messPos) INC messPos IF messPos >= messLen THEN messPos = 0 ENDIF segments(2) = message(messPos) INC messPos IF messPos >= messLen THEN messPos = 0 ENDIF segments(3) = message(messPos) INC messPos IF messPos >= messLen THEN messPos = 0 ENDIF messPos = messPos - 3 IF messPos >= messLen THEN messPos= messPos + messLen ENDIF DisplayArray PAUSE speed * 10 GOTO Main ' ------------------------------------------------------------------------- ' Subroutine Code ' ------------------------------------------------------------------------- DisplaySegments: PUT segments,__PARAM1,__PARAM2,__PARAM3,__PARAM4 DisplayArray: HIGH Clk LEDOut segments(3) LEDOut segments(2) LEDOut segments(1) LEDOut segments(0) RETURN LEDOut: temp1 = __PARAM1 SHIFTOUT Dat, Clk, MSBFIRST, temp1 RETURN