Cant change the color but the led count
Closed this issue · 1 comments
Tried with: Atmega168,Attiny261,Attiny461,Attiny861
The Microcontroller is connected with a stk500.
Connected without resistor.
Connected:
STK500 Attiny861 WS2812B
VCC VCC +(Red)
GND GND -(White)
MISO MISO
MOSI MOSI
SCK SCK
RST RESET
PB6/5/4 DATA(Green)
main.c:
`#define F_CPU 8000000UL
#include <util/delay.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include "light_ws2812.h"
struct cRGB led[6];
int main(void)
{
while(1)
{
led[0].r=255; led[0].g=1; led[0].b=1;
led[1].r=0; led[1].g=255; led[1].b=0;
ws2812_setleds(led,6);
_delay_ms(500);
led[0].r=0;led[0].g=255;led[0].b=0;
ws2812_setleds(led,6);
_delay_ms(500);
led[0].r=0;led[0].g=0;led[0].b=255;
ws2812_setleds(led,6);
_delay_ms(500);
}
}`
light_ws2812.h:
`#ifndef LIGHT_WS2812_H_
#define LIGHT_WS2812_H_
#include <avr/io.h>
#include <avr/interrupt.h>
#if !defined(ws2812_resettime)
#define ws2812_resettime 300
#endif
#if !defined(ws2812_port)
#define ws2812_port B // Data port
#endif
#if !defined(ws2812_pin)
#define ws2812_pin 6 // Data out pin
#endif
struct cRGB { uint8_t g; uint8_t r; uint8_t b; };
struct cRGBW { uint8_t g; uint8_t r; uint8_t b; uint8_t w;};
void ws2812_setleds (struct cRGB *ledarray, uint16_t number_of_leds);
void ws2812_setleds_pin (struct cRGB *ledarray, uint16_t number_of_leds,uint8_t pinmask);
void ws2812_setleds_rgbw(struct cRGBW *ledarray, uint16_t number_of_leds);
void ws2812_sendarray (uint8_t *array,uint16_t length);
void ws2812_sendarray_mask(uint8_t *array,uint16_t length, uint8_t pinmask);
#if !defined(CONCAT)
#define CONCAT(a, b) a ## b
#endif
#if !defined(CONCAT_EXP)
#define CONCAT_EXP(a, b) CONCAT(a, b)
#endif
#define ws2812_PORTREG CONCAT_EXP(PORT,ws2812_port)
#define ws2812_DDRREG CONCAT_EXP(DDR,ws2812_port)
#endif`
Not sure what the question is?