AVR Library for WS2803 LED Driver IC

ledySo today I will be sharing with you one of my maybe not so recent but reliable libraries. It is for WS2803 which I think is really cool IC that allows you to control outputs with PWM using SPI to control data being sent.


The amount of components needed is really minimal as we only need to provide one single reference resistor which will limit the amount of current for our outputs.


One thing you could ask is how do you connect to it without a lot of hustle ? Well I personally for my electronical challenges use ATB Development boards manufactured by Atnel.pl. Reason for this specific set ? Well first of all it is extremely high quality packed with all items which you would even imagine you could need 😀 Take a look …


What you see here below is previous version and the newest and shiniest version of ATB devboard.
2016-06-25 225703

2016-06-25 225650


Packed like this I’m ready to challenge the WS2803 … I won’t be providing connection schematics as internet and datasheet are available all over the internet.

Library is available under here and you can just go ahead and download it. Since I have been developing this on AVR Atmega32 it is using hardware SPI defined in SPI library.

The only pins you need there is MOSI and CLK. This is all needed to drive WS2803. Since there is no magic in sending data using SPI protocol let’s dive into WS803 library.

Before you begin I think you should now that I have written my own implementation of delay function. Reason for that is in this version I haven’t used interrupts and needed to be able to control delays with variables.

static inline void delay_ms(uint16_t count) 

Once you add library files to you project you will need to first define yourself buffer. I have tendency of defining how many outputs I will have and using that definition in the rest of my program.

So you could do the following to start …

define WS2803_LED_CNT 18 

uint8_t ws_buf[ WS2803_LED_CNT ];
uint8_t * ptrBuf = ws_buf;


Now we are ready to start fun…. easiest is to try and light out all of LEDs ( outputs ). For this we will use function which operating on memory sets all values in our buffer to single value

ws2803_set_all( ptrBuf , 255);    
ws2803_shift_out( ptrBuf ); 

Easy 🙂 Well – most up to date is always the github and there you will be able to find remaining functions and some examples i.e.

  • Fade in
  • Fade out
  • Draw line
  • Light up one by one



Leave a Reply

Your email address will not be published. Required fields are marked *