PICAXE 08M2 Silulated Filament Lamp Flash using a WS2801
Purpose : Flash a RGB LED using a WS2801 Driver to mimic the Point Abino Lighthouse incandescent filament flash.
Enjoy our 2 second, on/off cycle, simulation of the Point Abino Lighthouse flash.
NOTE: Add a 0.1 uF capacitor (that's the little yellow square thing in the photo.) near the WS2801 to prevent power supply transients from disrupting the display logic.
Photos
Figure
228
PICAXE 08M2 installed on a AXE091 Development Board wired to a WS2801 integrated driver and RGB LED.
Figure
229
Flash a RGB LED using a WS2801 Driver to mimic the Point Abino Lighthouse incandescent filament flash.
Figure
230
Flash a RGB LED using a WS2801 Driver to mimic the Point Abino Lighthouse incandescent filament flash.
Photo is for illustrative purposes only. Please refer to the description.
Code Sample
To copy code: Hover over the right top corner of the code panel. Click COPY button, the code will be COPIED to the clipboard.
#REM
===========================================================
File....... 08M2_WS2801_RGB_LED_LIGHTHOUSE_FLASH.bas
Purpose.... Flash a RGB LED using a WS2801 Driver to mimic a Lighthouse FLASH
Author..... radioSPARKS
Started.... rhb. 20240417
MODIFIED... rhb.20240419 for one WS2801
MOD........ rhb.20240505 added LOG function table
===========================================================
Enjoy our 2 second, on, off Cycle to minic the Point Abino Lighthouse flash
- --[ Program Description ]---------------------------------
A program to demonstrate the control of a RGB LED using a WS2801 driver chip
---[ Revision History ]------------------------------------
A = 20240418 Modified = 110 bytes
B = 20240419 Modified = 112 bytes
C = 20240420 Modified = 133 bytes
D = 20240506 Modified = 99 bytes
#ENDREM
; ---[ Compiler Directives ]----------------------------------
#PICAXE 08M2
SETFREQ M16
'#no_dat a ; REM to store EEPROM data in the PICAXE chip
; ---[ I/O Definitions ]------------------------------------
; - - - DIGITAL INPUT PINS - - -
SYMBOL MODE = C.3 ; Flash Mode Selector
; - - - DIGITAL OUTPUT PINS - - -
SYMBOL SData = pinC.2 ; SDI Pin on WS2801 - used to transfer 1 bit of data to a pin
SYMBOL S_Data = C.2 ; SDI Pin - also defined this way to use with the LOW command in Init:
SYMBOL SClock = C.1 ; CKI Pin on WS2801
; ---[ Constants ]-------------- -----------------------------
SYMBOL Step_Delay = 60 ; 4000 for 1 sec delay at 16 MHz
SYMBOL RAMbaseADDR = $08 ; 18M2=$80 08M2=$30
SYMBOL NUM_LED = 3 ; number of individual LED
; ---[ Variables ]---------------------------------------- ---
SYMBOL LED_Data = b0 ; NOTE: BIT register for SendData
SYMBOL MemAddr = b1
SYMBOL temp = b2
SYMBOL AllSent = b3
; ---[ EEPROM Data ]-----------------------------------------
' SHORT 19 logarithmic values - RAMP OFF/ON/OF F Data
EEPROM $00, (0,1,2,3,7,15,31,63,127,255,127,63,31,15,7,3,2,1,0)
; ---[ Initialization ]--------------------------------------
Init:
Low S_Data ; set pin as an output
Low SClock ; set pin as an output
AllSent = RAMbaseADDR + NUM_LED
; ---[ Program Code ]----------------------------------------
Main:
DO
MemAddr = 0 ; SET EEPROM data pointer to the first location
temp = 18
DO
IF MemAddr = 9 THEN
PAUSE 8000
END IF
INC MemAddr
READ MemA ddr, LED_Data
b8 = LED_Data
b9 = LED_Data
b10 = LED_Data
GOSUB SendData
LOOP UNTIL MemAddr = temp
PAUSE 8000
LOOP
; ---[ Subroutines ]----------------------------------------
; Subroutine to BIT-BANG ou t the data to the WS2801 chip
SendData:
bptr = RAMbaseADDR ; set the RAM address for RGB LED data
DO
LED_Data = @bptrinc ; load the data into b0 to extract each bit
SData = bit7 : PulsOut SClock, 1 ; msb first
SData = bit6 : Pu lsOut SClock, 1
SData = bit5 : PulsOut SClock, 1
SData = bit4 : PulsOut SClock, 1
SData = bit3 : PulsOut SClock, 1
SData = bit2 : PulsOut SClock, 1
SData = bit1 : PulsOut SClock, 1
SData = bit0 : PulsOut SClock, 1 ; lsb last
LOOP UNTI L bptr = AllSent ; continue until three bytes sent
PAUSE Step_Delay
RETURN