OK. So I have a program running fine on an ESP32, and I'm looking to convert it to run on a C3-mini.
I was advised to use Adafruit Neopixel, which has improved things a lot, but I'm struggling with some new errors.
#include <Adafruit_NeoPixel.h>
#define NUM_LEDS 60 // Number of LEDs
#define DATA_PIN 4 // Incoming Data from BT
#define LED_TYPE NEOPIXEL
#define COLOUR_ORDER GRB
#define BRIGHTNESSD 60
#define BRIGHTNESS 126
#define MAX_AMPS 500
int LED_SPEED = 10; // LED Speed - varies with Faster/Slower
int SOUND_VOLUME;
char SOUND_PLAYING;
char LED_COLOUR = 'B'; // LED Colour - varies Red/Blue/Green/White
char RUNNING = 'N'; // Defines whether light strip/sounds/buzzes are currently running Y = Yes, B = Brake (finish cycle then stop), N = No
#include "BluetoothSerial.h"
#define LEDpin 2 // The pin to which the LED is connected
BluetoothSerial SerialBT;
char command;
Adafruit_NeoPixel strip(NUM_LEDS, LEDpin, NEO_GRB + NEO_KHZ800);
void setup() {
{
Serial.begin(115200);
strip.begin();
strip.show(); // Initialize all pixels to 'off'
Serial.println("The device started, now you can pair it with Bluetooth!");
}
}
void loop() {
if (SerialBT.hasClient()) {
digitalWrite(LEDpin, HIGH); // Turn the LED on when connected
} else {
digitalWrite(LEDpin, LOW); // Turn the LED off when not connected
}
// DATA RECEIVED DATA RECEIVED DATA RECEIVED DATA RECEIVED
if (SerialBT.available()) {
char receivedChar = SerialBT.read();
{
Serial.println(receivedChar);
}
if (receivedChar == 'T') {
RUNNING = 'Y';
Serial.println(RUNNING);
}
if (receivedChar == 'O') {
RUNNING = 'B';
}
if (receivedChar == 'B') {
LED_COLOUR = 'B';
}
if (receivedChar == 'R') {
LED_COLOUR = 'R';
}
if (receivedChar == 'G') {
LED_COLOUR = 'G';
}
if (receivedChar == 'W') {
LED_COLOUR = 'W';
}
if (receivedChar == 'X') {
LED_COLOUR = 'X';
}
if (receivedChar == 'C') {
SOUND_PLAYING = 'T'; // Play Tick Tock
}
if (receivedChar == 'L') {
SOUND_PLAYING = 'B'; // Play Bell
}
if (receivedChar == 'Z') {
SOUND_PLAYING = 'Z'; // Turn Off Sound
}
if (receivedChar == '+') {
Serial.println(LED_SPEED);
int LEDSPEED = LED_SPEED - 1;
LED_SPEED = LEDSPEED;
Serial.println("+");
Serial.println(LED_SPEED);
}
if (receivedChar == '-') {
Serial.println(LED_SPEED);
int LEDSPEED = LED_SPEED + 1;
Serial.println("-");
Serial.println(LED_SPEED);
LED_SPEED == LEDSPEED;
}
// Make Brighter
if (receivedChar == 'S') {
int BRIGHTNESSDi = BRIGHTNESSD + 1;
int BRIGHTNESSi = BRIGHTNESS + 7;
BRIGHTNESSD == BRIGHTNESSDi;
BRIGHTNESS == BRIGHTNESSD;
}
if (receivedChar == 'R') {
int BRIGHTNESSDi = BRIGHTNESSD - 1;
int BRIGHTNESSi = BRIGHTNESS - 7;
BRIGHTNESSD == BRIGHTNESSDi;
BRIGHTNESS == BRIGHTNESSD;
}
}
// CYCLE CYCLE CYCLE CYCLE CYCLE CYCLE CYCLE CYCLE
if (RUNNING == 'Y' || RUNNING == 'B') {
Serial.println("CYCLE");
Serial.println(RUNNING);
if (RUNNING == 'B') {
RUNNING = 'N';
}
Serial.println(RUNNING);
// START - BLUE - BLUE - BLUE - BLUE
if (LED_COLOUR == 'B') {
for (int dot = 0; dot < NUM_LEDS; dot++) {
strip.setPixelColor(dot, 0, 0, BRIGHTNESS); // Blue LED
strip.show();
// clear this led for the next time around the loop
delay(LED_SPEED);
}
Serial.println("Blue R"); // PRINT "Blue R"
for (int dot = NUM_LEDS - 1; dot >= 0; dot--) {
strip.setPixelColor(dot, 0, 0, BRIGHTNESS);
strip.show();
// clear this led for the next time around the loop
strip.begin();
strip.show();
delay(LED_SPEED);
}
SerialBT.write(1);
Serial.println("Flash 1");
Serial.println("Blue L"); // PRINT "Blue L"
}
// END - BLUE - BLUE - BLUE - BLUE
// START - WHITE - WHITE - WHITE - WHITE
if (LED_COLOUR == 'W') {
for (int dot = 0; dot < NUM_LEDS; dot++) {
strip.setPixelColor(dot, BRIGHTNESS, BRIGHTNESS, BRIGHTNESS); // Blue LED
strip.show();
// clear this led for the next time around the loop
delay(LED_SPEED);
}
Serial.println("White R"); // PRINT "Blue R"
for (int dot = NUM_LEDS - 1; dot >= 0; dot--) {
strip.setPixelColor(dot, BRIGHTNESS, BRIGHTNESS, BRIGHTNESS);
strip.show();
// clear this led for the next time around the loop
strip.begin();
strip.show();
delay(LED_SPEED);
}
// END - WHITE - WHITE - WHITE - WHITE
// START - RED - RED - RED - RED - RED
if (LED_COLOUR == 'R') {
for (int dot = 0; dot < NUM_LEDS; dot++) {
strip.setPixelColor(dot, BRIGHTNESS, 0, 0); // Blue LED
strip.show();
// clear this led for the next time around the loop
delay(LED_SPEED);
}
Serial.println("Red R"); // PRINT "Blue R"
for (int dot = NUM_LEDS - 1; dot >= 0; dot--) {
strip.setPixelColor(dot, BRIGHTNESS, 0, 0);
strip.show();
// clear this led for the next time around the loop
strip.begin();
strip.show();
delay(LED_SPEED);
}
// END - RED - RED - RED - RED - RED
// START - GREEN - GREEN - GREEN - GREEN
if (LED_COLOUR == 'G') {
for (int dot = 0; dot < NUM_LEDS; dot++) {
strip.setPixelColor(dot, 0, BRIGHTNESS, 0); // Blue LED
strip.show();
// clear this led for the next time around the loop
delay(LED_SPEED);
}
Serial.println("Green R"); // PRINT "Blue R"
for (int dot = NUM_LEDS - 1; dot >= 0; dot--) {
strip.setPixelColor(dot, 0, BRIGHTNESS, 0);
strip.show();
// clear this led for the next time around the loop
strip.begin();
strip.show();
delay(LED_SPEED);
}
// END - GREEN - GREEN - GREEN - GREEN
// START - LBOff - LBOff - LBOff - LBOff
if (LED_COLOUR == 'X') {
for (int dot = 0; dot < NUM_LEDS; dot++) {
strip.begin(); // Green LEDs
strip.show();
// clear this led for the next time around the loop
}
Serial.println("LBOff"); //
}
// END - LBOff - LBOff - LBOff - LBOff
}
}
}
}
}
The errors I'm getting are:
c:/users/cex/appdata/local/arduino15/packages/esp32/tools/riscv32-esp-elf-gcc/esp-2021r2-patch5-8.4.0/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld.exe: C:\Users\cex\AppData\Local\Temp\arduino\sketches\68E0B262AF9CB632D1443F83FF0C871A\libraries\BluetoothSerial\BluetoothSerial.cpp.o: in function `.L0 ':
C:\Users\cex\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.11\libraries\BluetoothSerial\src/BluetoothSerial.cpp:713: undefined reference to `esp_spp_disconnect'
c:/users/cex/appdata/local/arduino15/packages/esp32/tools/riscv32-esp-elf-gcc/esp-2021r2-patch5-8.4.0/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld.exe: C:\Users\cex\AppData\Local\Temp\arduino\sketches\68E0B262AF9CB632D1443F83FF0C871A\libraries\BluetoothSerial\BluetoothSerial.cpp.o: in function `_stop_bt':
C:\Users\cex\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.11\libraries\BluetoothSerial\src/BluetoothSerial.cpp:714: undefined reference to `esp_spp_deinit'
collect2.exe: error: ld returned 1 exit status
Multiple libraries were found for "BluetoothSerial.h"
Used: C:\Users\cex\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.11\libraries\BluetoothSerial
Not used: C:\Users\cex\Documents\Arduino\libraries\BluetoothSerial
exit status 1
Compilation error: exit status 1
I'm a bit lost. I don't really understand why BluetoothSerial is suddenly duplicated, but as I read it this wouldn't be a terminal issue, unless this is causing the errors above, as well.
I'm sorry about this. I thought this transition would be (much) easier.
I'm not really sure why it isn't.