I have no idea why arduinoIDE can't recognize the function from FastLED library even though i already inlude and download the library,is it because the library doesn't work one esp32?when i try with uno it seems normal,is there something to do?please help me i appreciate it so much.
Thankyou in advance
The Uno is a 5V device whilst the ESP32 is a 3.3V device which could be the problem
Please post your test sketch and a schematic of your project using the ESP32
heres the sketch,can't compile it so not tested yet
#include "FastLED.h"
#include <FastLED_NeoPixel.h>
#include <BluetoothSerial.h>
BluetoothSerial serialBT;
#define DATA_PIN 2
#define NUM_LEDS 16
#define BRIGHTNESS 6
CRGB leds {NUM_LEDS};
char cmd;
int pola = 0;
void setup() {
Serial.begin(9600);
serialBT.begin("MAG");
FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
FastLED.setBrightness(BRIGHTNESS);
FastLED.setMaxPowerInVoltsAndMilliamps(5, 1500); // Set power limit dari LED strip ke 5V, 1500mA
FastLED.clear();
}
void loop() {
if (serialBT.available())
{
cmd = serialBT.read();
}
if (cmd == '1')
{
pola = 1;
}
if (cmd == '2')
{
pola = 2;
}
if (pola == 1)
{
FadeInOut(0x00,0xff,0xff);
}
if (pola == 2)
{
Fire(50, 100, 10);
}
if (cmd == '0')
{
pola = 0;
}
if (pola == 0)
{
FastLED.clear();
}
}
void FadeInOut(byte red, byte green, byte blue) {
float r, g, b;
for (int k = 0; k < 256; k = k + 1) {
r = (k / 256.0) * red;
g = (k / 256.0) * green;
b = (k / 256.0) * blue;
setAll(r, g, b);
}
for (int k = 255; k >= 0; k = k - 2) {
r = (k / 256.0) * red;
g = (k / 256.0) * green;
b = (k / 256.0) * blue;
setAll(r, g, b);
}
}
void showStrip() {
#ifdef ADAFRUIT_NEOPIXEL_H
// NeoPixel
strip.show();
#endif
#ifndef ADAFRUIT_NEOPIXEL_H
// FastLED
FastLED.show();
#endif
}
void setPixel(int Pixel, byte red, byte green, byte blue) {
#ifdef ADAFRUIT_NEOPIXEL_H
// NeoPixel
strip.setPixelColor(Pixel, strip.Color(red, green, blue));
#endif
#ifndef ADAFRUIT_NEOPIXEL_H
// FastLED
leds[Pixel].r = red;
leds[Pixel].g = green;
leds[Pixel].b = blue;
#endif
}
void setAll(byte red, byte green, byte blue) {
for (int i = 0; i < NUM_LEDS; i++ ) {
setPixel(i, red, green, blue);
}
showStrip();
strip.show();
}
void Fire(int FlameHeight, int Sparks, int DelayDuration) {
static byte heat[NUM_LEDS];
int cooldown;
// Cooldown setiap cell sedikit
for (int i = 0; i < NUM_LEDS; i++) {
cooldown = random(0, ((FlameHeight * 10) / NUM_LEDS) + 2);
if (cooldown > heat[i]) {
heat[i] = 0;
}
else {
heat[i] = heat[i] - cooldown;
}
}
// Heat looping di diffuse dikit dikit
for (int k = (NUM_LEDS - 1); k >= 2; k--) {
heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2]) / 3;
}
// akhir led kasih random epek
if (random(255) < Sparks) {
int y = random(7);
heat[y] = heat[y] + random(160, 255);
}
// Convert heat ke Led colors
for (int j = 0; j < NUM_LEDS; j++) {
setPixelHeatColor(j, heat[j]);
}
FastLED.show();
delay(DelayDuration);
}
void setPixelHeatColor(int Pixel, byte temperature) {
// Rescale heat 0-255 ke 0-191
byte t192 = round((temperature / 255.0) * 191);
// Calculate ramp up dari
byte heatramp = t192 & 0x3F; // 0...63
heatramp <<= 2; // scale up to 0...252
// Figure out which third of the spectrum we're in:
if (t192 > 0x80) { // paling panas
leds[Pixel].setRGB(255, 255, heatramp);
}
else if (t192 > 0x40) { // b aja
leds[Pixel].setRGB(255, heatramp, 0);
}
else { // terdingin
leds[Pixel].setRGB(heatramp, 0, 0);
}
}
b707
March 13, 2023, 12:15pm
4
Please show the exact compiler error message using the code tags.
`exit status 1
no matching function for call to 'CFastLED::addLeds<WS2812B, 2, GRB>(CRGB&, int)'
`
b707
March 13, 2023, 12:30pm
6
Note the difference between "{}" and "[ ]" .
This line defined single int leds
variable with value NUM_LEDS.
mochammad_gojo:
CRGB leds {NUM_LEDS};
but library needs an array.
Change the line to
CRGB leds [NUM_LEDS];
and try again
A... it fixed,noted,thank you mr b707
b707
March 13, 2023, 12:42pm
8
Please mark the thread as solved
system
Closed
September 9, 2023, 12:43pm
9
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.