Skip to content
/ WS2812 Public

Fast and light weight header-only library written in C for WS2812 based LEDs.

License

Notifications You must be signed in to change notification settings

pufmat/WS2812

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Pufferfish's WS2812

Fast and light weight header-only library written in C for WS2812 based LEDs. Only supports 8MHz AVR microcontrollers.

Example

Rainbow Chase:

#include "ws2812.h"
#include <util/delay.h>

#define LED_COUNT    30
#define LED_PORT     PORTB
#define LED_DDR      DDRB
#define LED_MASK     _BV(1)

PUF_WS2812(write_ws2812, LED_PORT)

uint8_t data[LED_COUNT * 3];

int main(){
    LED_DDR |= LED_MASK;
    
    while(1){
        for(int i = 0; i < 18; i += 3){
            for(int j = 0; j < LED_COUNT * 3; j++){
                data[j] = ((i + j) * 10 + 4) / 18 % 2 * 255;
            }
            
            write_ws2812(data, LED_COUNT, LED_MASK);
            _delay_ms(250);
        }
    }
}

About

Fast and light weight header-only library written in C for WS2812 based LEDs.

Topics

Resources

License

Stars

Watchers

Forks

Languages