I am trying to pass two values into my Arduino script from a Bluetooth serial connection.
The first part of the string received is the LED number, the second is the LED color in the form of a hex code (0x000000).
The first variable is converted and working fine, but when I try to pass the color value I get an error saying the operand has to be CRGB
or String
.
I don't know why it is throwing an error when I am passing it a string. Is there a way to force upload past this error because it is a mistake, or am I missing something?
Here is my code:
#include "BluetoothSerial.h"
#include <FastLED.h>
#define DATA_PIN 22
#define LED_TYPE WS2812B
#define COLOR_ORDER GRB
#define NUM_LEDS 120
#define BRIGHTNESS 23
#define x inputFromOtherSide.substring(3,6).toInt()
CRGB leds[NUM_LEDS];
BluetoothSerial SerialBT;
void setup() {
// tell FastLED about the LED strip configuration
FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS);
// set master brightness control
FastLED.setBrightness(BRIGHTNESS);
Serial.begin(115200);
Serial.println("Serial Port Started");
SerialBT.begin("ESP32test");
Serial.println("Bluetooth Started");
}
void loop() {
String inputFromOtherSide;
if (SerialBT.available()) {
inputFromOtherSide = SerialBT.readString();
Serial.println("Data Recieved: ");
Serial.println(inputFromOtherSide);
delay(500);
Serial.println(inputFromOtherSide.substring(3,6));
Serial.println(inputFromOtherSide.substring(11));
leds[x] = inputFromOtherSide.substring(11);
FastLED.show();
}
}