Hi,
I have a bare ATTiny85 and I want to control some 800KHz SK6812s. My problem is that both, NeoPixel and FastLED do have wrong timing (400KHz). Also delay(d)
takes twice as long as it should. The ATTiny is running at 8MHz - it still has the default fuses:
avrdude: safemode: Fuses OK (E:FF, H:DF, L:62)
I tried everything to set the Frequency to 8MHz during compiling. This is my platformio.ini
:
[env:attiny85]
platform = atmelavr
board = attiny85
upload_protocol = avrisp ; Arduino as ISP
upload_flags =
-PCOM8
-b19200
framework = arduino
build_flags =
-DF_CPU=8000000L
board_build.mcu = attiny85
board_build.f_cpu = 8000000L
lib_deps = adafruit/Adafruit NeoPixel @ 1.10.0
This is my main.cpp
:
#include <Arduino.h>
#include <Adafruit_NeoPixel.h>
const uint8_t LED_PIN = PB0;
Adafruit_NeoPixel strip = Adafruit_NeoPixel(3, LED_PIN, NEO_GRB + NEO_KHZ800);
void setup() {
strip.begin();
strip.setBrightness(50);
strip.show(); // Initialize all pixels to 'off'
}
void loop() {
for(uint8_t i=0; i<3; i++) strip.setPixelColor(i, strip.Color(50, 0, 0)); strip.show(); delay(12);
for(uint8_t i=0; i<3; i++) strip.setPixelColor(i, strip.Color(0, 50, 0)); strip.show(); delay(12);
for(uint8_t i=0; i<3; i++) strip.setPixelColor(i, strip.Color(0, 0, 50)); strip.show(); delay(12);
for(uint8_t i=0; i<3; i++) strip.setPixelColor(i, strip.Color(50, 50, 50)); strip.show(); delay(12);
for(uint8_t i=0; i<3; i++) strip.setPixelColor(i, strip.Color(0, 0, 0)); strip.show(); delay(12);
}
The compiler actually knows the frequency, because when I set it to 4000000L
FastLED and NeoPixel complain during compiling that the CPU frequency is not supported.
However, with 8MHz, the timing is wrong…
What am I doing wrong?