RGB LED Strip Code

Hey guys,

I’ve checked the code I’m trying to use multiple times, but I don’t get what I’m missing. Bear in mind this is the first time I’m working with code - this isn’t my code, but I’ve formatted it, added a few things and changed some values. As such I’m still trying to get my head around how everything in this code works. Can you guys see anything that’s wrong at first glance? This is the error I’m getting:

RGB_LED_Strip_Code:60: error: expected unqualified-id before '{' token
 {
 ^
RGB_LED_Strip_Code:67: error: expected unqualified-id before '{' token
 {
 ^
RGB_LED_Strip_Code:74: error: expected unqualified-id before '{' token
 {
 ^
RGB_LED_Strip_Code:81: error: expected unqualified-id before '{' token
 {
 ^
exit status 1
expected unqualified-id before '{' token

And this is the code:

#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>


int RedP = 15;
int GrnP = 13;
int BluP = 12;

char auth[] = "*******";

char ssid[] = "******";
char pass[] = "*****";


WidgetLED vRGB(V9);  // Set virtual RGB widget.
int rrr, ggg, bbb;  // Set RED BLUE GREEN channels


void setup() 
{
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  pinMode(RedP, OUTPUT);  // Set RED on RGB LED.
  pinMode(GrnP, OUTPUT);  // Set GREEN on RGB LED.
  pinMode(BluP, OUTPUT);  // Set BLUE on RGB LED.

}

  void RGBprocess()
{  // Pin data to HEX conversion funtion.
  analogWrite(RedP, rrr);  // Write to RED RGB pin.
  analogWrite(GrnP, ggg);  // Write to GREEN RGB pin.
  analogWrite(BluP, bbb);  // Write to BLUE RGB pin.
  String strRED = String(rrr, HEX);  // Convert RED DEC to HEX.
  if (rrr < 16) {
    strRED = String("0" + strRED);  // Buffer with 0 if required.
  }  // END if
  String strGRN = String(ggg, HEX);  // Convert GREEN DEC to HEX.
  if (ggg < 16)  {
    strGRN = String("0" + strGRN);  // Buffer with 0 if required.
  }  // END if
  String strBLU = String(bbb, HEX);  // Convert BLUE DEC to HEX.
  if (bbb < 16)  {
    strBLU = String("0" + strBLU);  // Buffer with 0 if required.
  }  // END if
  String HEXstring = String("#" + strRED + strGRN + strBLU);  // Combine HEX fragments.
  Blynk.run();
  HEXstring.toUpperCase();  // Change HEX value to all upper case for ease of visuals.
  Blynk.setProperty(V8, "color", HEXstring);  // Change background colour of HEX Data Label.
  Blynk.virtualWrite(V8, HEXstring);  // Display HEX data.
  Blynk.setProperty(V9, "color", HEXstring);  // Send formatted HEX colour to vRGB.
  Blynk.virtualWrite(V9, 255);  // Activate vRGB.
}  // END Blynk Function


BLYNK_WRITE(V20);  // RED slider.
{
  int rrr = param.asInt(); // get a RED channel value.
  Blynk.virtualWrite(V23, rrr);  // Red LED intensity
  RGBprocess();  // Goto pin data to HEX conversion funtion.
}  // END Blynk Function

BLYNK_WRITE(V21);  // GREEN slider.
{
  int ggg = param.asInt(); // get a GREEN channel value.
  Blynk.virtualWrite(V24, ggg);  // Green LED intensity
  RGBprocess();  // Goto pin data to HEX conversion funtion.
}  // END Blynk Function

BLYNK_WRITE(V22);  // BLUE slider.
{
  int bbb = param.asInt(); // get a BLUE channel value.
  Blynk.virtualWrite(V25, bbb);  // Blue LED intensity
  RGBprocess();  // Goto pin data to HEX conversion funtion.
}  // END Blynk Function

BLYNK_WRITE(V2);
{
  int rrr = param[0].asInt(); // get a RED channel value.
  int ggg = param[1].asInt(); // get a GREEN channel value.
  int bbb = param[2].asInt(); // get a BLUE channel value.
  Blynk.virtualWrite(V20, rrr);  // Red slider position.
  Blynk.virtualWrite(V23, rrr);  // Red LED intensity.
  Blynk.virtualWrite(V21, ggg);  // Green slider position.
  Blynk.virtualWrite(V24, ggg);  // Green LED intensity.
  Blynk.virtualWrite(V22, bbb);  // Blue slider position.
  Blynk.virtualWrite(V25, bbb);  // Blue LED intensity.
  Blynk.run();
  RGBprocess();
}  

void loop()
{
  Blynk.run();
}

Thanks so much!
-Casper

Try removing the semicolons after the BLINK_WRITE() routine definitions for V2, V22, V21, V20. Compiles.

3 Likes