BLYNK
BLYNK.IO       📲 GETTING STARTED       📗 DOCS       👉 SKETCH BUILDER

Keeps giving me "expected primary-expression before '{' token"

keeps giving me “expected primary-expression before ‘{’ token” errors. rather new to Arduino and programming so I’m unsure as to what I’m doing wrong exactly. I appreciate any help.

#define BLYNK_TEMPLATE_ID "---------"
#define BLYNK_DEVICE_NAME "-----------"

#define BLYNK_FIRMWARE_VERSION        "0.1.0"
#define BLYNK_PRINT Serial
#define APP_DEBUG
#define USE_ESP32S2_DEV_KIT
#include "BlynkEdgent.h"


#include <ShiftRegister74HC595.h>
#include <Arduino.h>

// parameters: <number of shift registers> (data pin, clock pin, latch pin)
ShiftRegister74HC595<3> sr(18, 16, 17);

BlynkTimer leddisplay;

BlynkTimer motor;

const int big_sha_up = 9; //shift register pin 
const int big_sha_down = 10; //shift register pin 
const int smol_sha_up = 22; //shift register pin 
const int smol_sha_down = 23; //shift register pin 
const int big_win_close = 21; //shift register pin 
const int big_win_open = 20; //shift register pin 
const int smol_win_open = 18; //shift register pin 
const int smol_win_close = 19; //shift register pin 


bool blinky = false;

//states of the windows and blinds
bool smol_sha = true;
bool smol_win = true;
bool big_win = true;
bool big_sha = true;

bool everything_close = false;
bool everything_open = false;

BLYNK_WRITE(V7)//--------------------------------------------------------------------Open everything
{

  if (param.asInt() == 1)
  {
    blinky = true;

    if (everything_close == false && everything_open == false)
    {
      everything_open = true;
    }
  }
}
    

BLYNK_WRITE(V6)//--------------------------------------------------------------------close everything
{

  if (param.asInt() == 1)
  {
    blinky = true;

    if (everything_close == false && everything_open == false)
    {
      everything_close = true;
    }
  }
}

void setup()
{
  Serial.begin(115200);
  delay(100);

  sr.setAllLow();
 
  leddisplay.setInterval(1, Leddisplay);
  motor.setInterval(1,Motor);
  
  delay(100);

  BlynkEdgent.begin();
}

void loop() {
  BlynkEdgent.run();
  leddisplay.run();
  motor.run();
}

void Motor()//======================================================================================
{
  if (everything_open == true && everything_close == false)//--------------------------open everything
  {
    if (big_sha == true)-------------//Open the big shades
    {
      sr.set(big_sha_up,HIGH);
      delay(500);//
      sr.set(big_sha_up,LOW);
      delay(500);
      sr.set(big_sha_up,HIGH);
      delay(500);//
      sr.set(big_sha_up,LOW);
      delay(500);
      sr.set(big_sha_up,HIGH);
      delay(500);//
      sr.set(big_sha_up,LOW);
      delay(500);
      sr.set(big_sha_up,HIGH);
      delay(500);//
      sr.set(big_sha_up,LOW);
      delay(500);
      sr.set(big_sha_up,HIGH);
      delay(500);//
      sr.set(big_sha_up,LOW);
      delay(500);
      sr.set(big_sha_up,HIGH);
      delay(500);//
      sr.set(big_sha_up,LOW);
      delay(500);
      sr.set(big_sha_up,HIGH);
      delay(500);//
      sr.set(big_sha_up,LOW);
      
      delay(1000);
      big_sha = false;
      delay(1000);
    }

    if (smol_sha == true)----------//open the smol shades
    {
      sr.set(smol_sha_up,HIGH);
      delay(2000);
      sr.set(smol_sha_up,LOW);
      
      delay(1000);
      smol_sha = false;
      delay(1000);
    }

    if (big_win == true)-------------//open the big windows
    {
      sr.set(big_win_open,HIGH);
      delay(24600);
      sr.set(big_win_open,LOW);

      delay(1000);
      big_win = false;
      delay(1000);
    }
    delay(1000);

    if (smol_win == true)------------//open the smol windows
    {
      sr.set(smol_win_open,HIGH);
      delay(24600);
      sr.set(smol_win_open,LOW);

      delay(1000);
      smol_win = false;
      delay(1000);
    }
    delay(1000);
    
    everything_open = false;
    blinky = false;
  }
  
  if (everything_close == true && everything_open == false)//-------------close everything
  {
    if (big_win == false)//-----------close big windows
    {
      sr.set(big_win_close,HIGH);
      delay(35000);
      sr.set(big_win_close,LOW);

      delay(1000);
      big_win = true;
      delay(1000);
    }

    if (smol_win == false)//---------------------close smol window
    {
      sr.set(smol_win_close,HIGH);
      delay(33000);
      sr.set(smol_win_close,LOW);

      delay(1000);
      smol_win = true;
      delay(1000);
    }

    if (big_sha == false)//----------------------------close big shades
    {
      sr.set(big_sha_down,HIGH);
      delay(500);
      sr.set(big_sha_down,LOW);
      delay(500);
      sr.set(big_sha_down,HIGH);
      delay(500);
      sr.set(big_sha_down,LOW);
      delay(500);
      sr.set(big_sha_down,HIGH);
      delay(800);
      sr.set(big_sha_down,LOW);

      delay(1000);
      big_sha = true;
      delay(1000);
    }

    if (smol_sha == false)//-------------------------------smol shades
    {
      sr.set(smol_sha_down,HIGH);
      delay(2000);
      sr.set(smol_sha_down,HIGH);
    }
    everything_close = false;
    blinky = false;
  }
}

void Leddisplay()//========================================================================================================================================
{
  if (blinky == true)
  {
    sr.set(8,HIGH);
    delay(500);
    sr.set(8,HIGH);
    delay(500);
  }
}

full error code

‘’’ Arduino: 1.8.19 (Windows 10), Board: “ESP32 Dev Module, Disabled, Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS), 240MHz (WiFi/BT), QIO, 80MHz, 4MB (32Mb), 921600, Core 1, Core 1, None”

C:\Users\ADITYA~1\AppData\Local\Temp\arduino_modified_sketch_804741\Edgent_ESP32.ino: In function ‘void Motor()’:

Edgent_ESP32:98:5: error: expected primary-expression before ‘{’ token

 {

 ^

Edgent_ESP32:133:5: error: expected primary-expression before ‘{’ token

 {

 ^

Edgent_ESP32:144:5: error: expected primary-expression before ‘{’ token

 {

 ^

Edgent_ESP32:156:5: error: expected primary-expression before ‘{’ token

 {

 ^

exit status 1

expected primary-expression before ‘{’ token

‘’’

Your opening and closing curly brackets don’t match.

But, when you fix that the code won’t work well because of all the blocking delays in your code.

Pete.

:scream::scream::scream::scream::scream:

I think we should make our beloved Blynk to work with the all time favourite delay !! Thats sooooo yummy :yum: :sweat_smile::sweat_smile::sweat_smile::sweat_smile:

Everyone loves delay !! :crazy_face::stuck_out_tongue_winking_eye:

1 Like

This seems like opting for extra toppings on pizza :pizza::sweat_smile:

1 Like

Have you not learnt how to use millis() as a method of timing?