Having trouble with the coding

Before this happens, i insert the SimpleTimer Library from the Github and include the library in the coding, but it is no recognised when i deleted the coding and back to this one and

this appear “Error Compiling for Board Arduino/Genuino or Mega 2560”
how to fix this?

#include <BlynkSimpleStream.h>
BlynkTimer timer;
char auth[] = "cabb6d95d9804956b25f9e4553fc10b8";


int GreenMe  =4 ;                                               
int YellowMe =3 ;                                               
int RedMe    =2 ;                                               

int EchoMe   =22 ;                                              
int TrigMe   =23 ;                                               
float pingUS1   ;                                              
float targetDUS1;                                               

                                                                
String GarbageCaps1me="The Garbage Capacity for Metal is 0%";   
String GarbageCaps2me="The Garbage Capacity for Metal is 50%"; 
String GarbageCaps3me="The Garbage Capacity is for Metal 100%";

                                                                 
int GreenNo  =10;                                               
int YellowNo =9;                                                                                          
int RedNo    =8;                                               

int EchoNo   =26;                                                
int TrigNo   =27;                                                 
float pingUS2;                                       
float targetDUS2;                                        
                                                                 
                                                                 
String GarbageCaps1no="The Garbage Capacity for Non-Metal is 0%";
String GarbageCaps2no="The Garbage Capacity is Non-Metal 50%";  
String GarbageCaps3no="The Garbage Capacity is Non-Metal 100%"; 

float speedOfSound=776.5;                                       
String GarbageLCD="Garbage Capacity";      

BLYNK_WRITE(V10)
BLYNK_WRITE(V12)
                     
void setup() 
{
 Serial.begin(9600);
 Serial1.begin(9600);
 Blynk.begin(Serial, auth);

 pinMode(EchoMe, INPUT);
 pinMode(TrigMe, OUTPUT);
 pinMode(EchoNo, INPUT);
 pinMode(TrigNo, OUTPUT);
 timer.setInterval(1000, USMe, USNo);
 
}

void USMe()
{
  digitalWrite(TrigMe, LOW);                                  
  delayMicroseconds(100);                                       
  digitalWrite(TrigMe, HIGH);                               
  delayMicroseconds(20);                                       
  digitalWrite(TrigMe, LOW);                                  
  
  pingUS1 = pulseIn(EchoMe, HIGH);                          
  pingUS1 = pingUS1/1000000;                                 
  pingUS1 = pingUS1/3600;                                     
  targetDUS1 = speedOfSound*pingUS1;                    
  targetDUS1 = targetDUS1/2;                            
  targetDUS1 = targetDUS1*63360;                       
  targetDUS1 = targetDUS1*2.54;                         
  Serial.print("The distance to the trash is: ");             
  Serial.print(targetDUS1);                                
  Serial.println(" centimeters");                             
  delay(1000);
  Blynk.virtualWrite(V10, targetDUS1);                                               

  if (targetDUS1 < 10)                                     
  { 
    Serial.println(GarbageCaps3me);                           
    analogWrite(RedMe, 250);                                                              
    delay(1000);                                              
    analogWrite(RedMe, 0);                                
    delay(100);
  }
  
  if (targetDUS1 >= 11 && targetDUS1 <= 20)            
  {
    Serial.println(GarbageCaps2me);                                                             
    analogWrite(YellowMe, 250);                            
    delay(1000);                                             
    analogWrite(YellowMe, 0);                            
    delay(100);   
  }
  
  if (targetDUS1 >20)                                    
  {  
    Serial.print(GarbageCaps1me);                           
    analogWrite(GreenMe, 250);                            
    delay(1000);                                             
    analogWrite(GreenMe, 0);                               
    delay(100);          
  }
}


void USNo()
{
  digitalWrite(TrigNo, LOW);                             
  delayMicroseconds(100);                                 
  digitalWrite(TrigNo, HIGH);                             
  delayMicroseconds(20);                                     
  digitalWrite(TrigNo, LOW);                             
  
  pingUS2 = pulseIn(EchoNo, HIGH);                           
  pingUS2 = pingUS2/1000000;                                 
  pingUS2 = pingUS2/3600;                                 
  targetDUS2 = speedOfSound*pingUS2;                   
  targetDUS2 = targetDUS2/2;                         
  targetDUS2 = targetDUS2*63360;                      
  targetDUS2 = targetDUS2*2.54;                         
  Serial.print("The distance to the trash is: ");             
  Serial.print(targetDUS2);                                
  Serial.println(" centimeters");                           
  delay(1000);
  Blynk.virtualWrite(V12, targetDUS2);

  
  if (targetDUS2 < 10)                              
  { 
    Serial.println(GarbageCaps3no);                  
    analogWrite(RedNo, 250);                      
    delay(1000);                                     
    analogWrite(RedNo, 0);                                  
    delay(100);
  }
  
  if (targetDUS2 >= 11 && targetDUS2 <= 20)           
  {
    Serial.println(GarbageCaps2no);                                                               
    analogWrite(YellowNo, 250);                             
    delay(1000);                                                
    analogWrite(YellowNo, 0);                               
    delay(100); 
  }
  
  if (targetDUS2 >20)                                       
  {     
    Serial.print(GarbageCaps1no);                              
    analogWrite(GreenNo, 250);                              
    delay(1000);                                                
    analogWrite(GreenNo, 0);                                
    delay(100);
  } 
}

void loop() 
{
  USMe();
  USNo();
  delay(1000);
  Blynk.run();
  timer.run(); 
}

The Blynk simple timer is included in the Blynk library and no explicit #include is needed for it to work

Your problem lies with the syntax of these two “functions”:

Pete.

after correcting your code as @PeteKnight suggested,
you will have to clean the void loop, otherwise you will have disconnections

void loop() 
{
  Blynk.run();
  timer.run(); 
}
1 Like

@RavenLeox As per your prior account @Shfq_Slmt and post on same issue… it was automatically blocked due to “typing to fast”… AKA probably copy pasting everything in one shot on a new account? Or other activity? :stuck_out_tongue_winking_eye:

https://community.blynk.cc/t/problem-with-blynk-and-coding/29211

It has been unblocked… but which account do you wish to continue with? I will close out the other.

Yup, same account. Its weird at that time, i wonder i got blocked.

I wish to continue it here, usually i testing the coding at night before i post it here

1 Like

meaning by cleaning the void loop? on what, how?

After removing the Blynk Write V10 and V12 as you mentioned, the other problem is that the gauge/visual display that i placed in the blynk apps did not work


#define BLYNK_PRINT Serial1
#include <BlynkSimpleStream.h>
BlynkTimer timer;
char auth[] = "cabb6d95d9804956b25f9e4553fc10b8";


int GreenMe  =4 ;                                               
int YellowMe =3 ;                                               
int RedMe    =2 ;                                               

int EchoMe   =22 ;                                              
int TrigMe   =23 ;                                               
float pingUS1   ;                                              
float targetDUS1;                                               

                                                                
String GarbageCaps1me="The Garbage Capacity for Metal is 0%";   
String GarbageCaps2me="The Garbage Capacity for Metal is 50%"; 
String GarbageCaps3me="The Garbage Capacity is for Metal 100%";

                                                                 
int GreenNo  =10;                                               
int YellowNo =9;                                                                                          
int RedNo    =8;                                               

int EchoNo   =26;                                                
int TrigNo   =27;                                                 
float pingUS2;                                       
float targetDUS2;                                        
                                                                 
                                                                 
String GarbageCaps1no="The Garbage Capacity for Non-Metal is 0%";
String GarbageCaps2no="The Garbage Capacity is Non-Metal 50%";  
String GarbageCaps3no="The Garbage Capacity is Non-Metal 100%"; 

float speedOfSound=776.5;                                       
String GarbageLCD="Garbage Capacity";      
      
void setup() 
{
 Serial.begin(9600);
 Serial1.begin(9600);
 Blynk.begin(Serial, auth);

 pinMode(EchoMe, INPUT);
 pinMode(TrigMe, OUTPUT);
 pinMode(EchoNo, INPUT);
 pinMode(TrigNo, OUTPUT);
 timer.setInterval(1000, USMe, USNo);
 
}

void USMe()
{
  digitalWrite(TrigMe, LOW);                                  
  delayMicroseconds(100);                                       
  digitalWrite(TrigMe, HIGH);                               
  delayMicroseconds(20);                                       
  digitalWrite(TrigMe, LOW);                                  
  
  pingUS1 = pulseIn(EchoMe, HIGH);                          
  pingUS1 = pingUS1/1000000;                                 
  pingUS1 = pingUS1/3600;                                     
  targetDUS1 = speedOfSound*pingUS1;                    
  targetDUS1 = targetDUS1/2;                            
  targetDUS1 = targetDUS1*63360;                       
  targetDUS1 = targetDUS1*2.54;                         
  Serial.print("The distance to the trash is: ");             
  Serial.print(targetDUS1);                                
  Serial.println(" centimeters");                             
  delay(1000);
  Blynk.virtualWrite(V10, targetDUS1);                                               

  if (targetDUS1 < 10)                                     
  { 
    Serial.println(GarbageCaps3me);                           
    analogWrite(RedMe, 250);                                                              
    delay(1000);                                              
    analogWrite(RedMe, 0);                                
    delay(100);
  }
  
  if (targetDUS1 >= 11 && targetDUS1 <= 20)            
  {
    Serial.println(GarbageCaps2me);                                                             
    analogWrite(YellowMe, 250);                            
    delay(1000);                                             
    analogWrite(YellowMe, 0);                            
    delay(100);   
  }
  
  if (targetDUS1 >20)                                    
  {  
    Serial.print(GarbageCaps1me);                           
    analogWrite(GreenMe, 250);                            
    delay(1000);                                             
    analogWrite(GreenMe, 0);                               
    delay(100);          
  }
}


void USNo()
{
  digitalWrite(TrigNo, LOW);                             
  delayMicroseconds(100);                                 
  digitalWrite(TrigNo, HIGH);                             
  delayMicroseconds(20);                                     
  digitalWrite(TrigNo, LOW);                             
  
  pingUS2 = pulseIn(EchoNo, HIGH);                           
  pingUS2 = pingUS2/1000000;                                 
  pingUS2 = pingUS2/3600;                                 
  targetDUS2 = speedOfSound*pingUS2;                   
  targetDUS2 = targetDUS2/2;                         
  targetDUS2 = targetDUS2*63360;                      
  targetDUS2 = targetDUS2*2.54;                         
  Serial.print("The distance to the trash is: ");             
  Serial.print(targetDUS2);                                
  Serial.println(" centimeters");                           
  delay(1000);
  Blynk.virtualWrite(V12, targetDUS2);

  
  if (targetDUS2 < 10)                              
  { 
    Serial.println(GarbageCaps3no);                  
    analogWrite(RedNo, 250);                      
    delay(1000);                                     
    analogWrite(RedNo, 0);                                  
    delay(100);
  }
  
  if (targetDUS2 >= 11 && targetDUS2 <= 20)           
  {
    Serial.println(GarbageCaps2no);                                                               
    analogWrite(YellowNo, 250);                             
    delay(1000);                                                
    analogWrite(YellowNo, 0);                               
    delay(100); 
  }
  
  if (targetDUS2 >20)                                       
  {     
    Serial.print(GarbageCaps1no);                              
    analogWrite(GreenNo, 250);                              
    delay(1000);                                                
    analogWrite(GreenNo, 0);                                
    delay(100);
  } 
}

void loop() 
{
  USMe();
  USNo();
  delay(1000);
  Blynk.run();
  timer.run(); 
}

Same thing I had mentioned on your other topic…

Calling those functions thousands of times a second is no better then leaving all their code in the void loop() Learn to use timers.

And crippling the void loop(), or anywhere else in your code, with blocking commands like delay() is very bad Blynk form :hushed: Again… timers…

Please read the documentation and help files…

http://help.blynk.cc/getting-started-library-auth-token-code-examples/blynk-basics/keep-your-void-loop-clean

1 Like

@Gunner
you beat me :smile:

2 Likes

Even the timer has been inserted but still has no output on the blnyk apps

#include <BlynkSimpleStream.h>
BlynkTimer timer;
char auth[] = "cabb6d95d9804956b25f9e4553fc10b8";


int GreenMe  =4 ;                                               
int YellowMe =3 ;                                               
int RedMe    =2 ;                                               

int EchoMe   =38 ;                                              
int TrigMe   =39 ;                                               
float pingUS1   ;                                              
float targetDUS1;                                               

                                                                
String GarbageCaps1me="The Garbage Capacity for Metal is 0%";   
String GarbageCaps2me="The Garbage Capacity for Metal is 50%"; 
String GarbageCaps3me="The Garbage Capacity is for Metal 100%";

                                                                 
int GreenNo  =10;                                               
int YellowNo =9;                                                                                          
int RedNo    =8;                                               

int EchoNo   =44;                                                
int TrigNo   =45;                                                 
float pingUS2;                                       
float targetDUS2;                                        
                                                                 
                                                                 
String GarbageCaps1no="The Garbage Capacity for Non-Metal is 0%";
String GarbageCaps2no="The Garbage Capacity is Non-Metal 50%";  
String GarbageCaps3no="The Garbage Capacity is Non-Metal 100%"; 

float speedOfSound=776.5;                                       
String GarbageLCD="Garbage Capacity";      
        
void setup() 
{
 Serial.begin(9600);
 Serial1.begin(9600);
 Blynk.begin(Serial, auth);

 pinMode(EchoMe, INPUT);
 pinMode(TrigMe, OUTPUT);
 pinMode(EchoNo, INPUT);
 pinMode(TrigNo, OUTPUT);
 timer.setInterval(1200L, USMe);
 timer.setInterval(1200L, USNo);
 
}

void USMe()
{
  digitalWrite(TrigMe, LOW);                                  
  delayMicroseconds(100);                                       
  digitalWrite(TrigMe, HIGH);                               
  delayMicroseconds(20);                                       
  digitalWrite(TrigMe, LOW);                                  
  
  pingUS1 = pulseIn(EchoMe, HIGH);                          
  pingUS1 = pingUS1/1000000;                                 
  pingUS1 = pingUS1/3600;                                     
  targetDUS1 = speedOfSound*pingUS1;                    
  targetDUS1 = targetDUS1/2;                            
  targetDUS1 = targetDUS1*63360;                       
  targetDUS1 = targetDUS1*2.54;                         
  Serial.print("The distance to the trash is: ");             
  Serial.print(targetDUS1);                                
  Serial.println(" centimeters");
  Serial.println(" ");                              
  delay(1000);
                                                 

  if (targetDUS1 < 10)                                     
  { 
    Serial.println(GarbageCaps3me);                           
    analogWrite(RedMe, 250);                                                              
    delay(1000);                                              
    analogWrite(RedMe, 0);                                
    delay(100);
  }
  
  if (targetDUS1 >= 11 && targetDUS1 <= 20)            
  {
    Serial.println(GarbageCaps2me);                                                             
    analogWrite(YellowMe, 250);                            
    delay(1000);                                             
    analogWrite(YellowMe, 0);                            
    delay(100);   
  }
  
  if (targetDUS1 >20)                                    
  {  
    Serial.print(GarbageCaps1me);                           
    analogWrite(GreenMe, 250);                            
    delay(1000);                                             
    analogWrite(GreenMe, 0);                               
    delay(100);          
  }
}


void USNo()
{
  digitalWrite(TrigNo, LOW);                             
  delayMicroseconds(100);                                 
  digitalWrite(TrigNo, HIGH);                             
  delayMicroseconds(20);                                     
  digitalWrite(TrigNo, LOW);                             
  
  pingUS2 = pulseIn(EchoNo, HIGH);                           
  pingUS2 = pingUS2/1000000;                                 
  pingUS2 = pingUS2/3600;                                 
  targetDUS2 = speedOfSound*pingUS2;                   
  targetDUS2 = targetDUS2/2;                         
  targetDUS2 = targetDUS2*63360;                      
  targetDUS2 = targetDUS2*2.54;                         
  Serial.print("The distance to the trash is: ");             
  Serial.print(targetDUS2);                                
  Serial.println(" centimeters");
  Serial.println(" ");                              
  delay(1000);
  

  
  if (targetDUS2 < 10)                              
  { 
    Serial.println(GarbageCaps3no);                  
    analogWrite(RedNo, 250);                      
    delay(1000);                                     
    analogWrite(RedNo, 0);                                  
    delay(100);
  }
  
  if (targetDUS2 >= 11 && targetDUS2 <= 20)           
  {
    Serial.println(GarbageCaps2no);                                                               
    analogWrite(YellowNo, 250);                             
    delay(1000);                                                
    analogWrite(YellowNo, 0);                               
    delay(100); 
  }
  
  if (targetDUS2 >20)                                       
  {     
    Serial.print(GarbageCaps1no);                              
    analogWrite(GreenNo, 250);                              
    delay(1000);                                                
    analogWrite(GreenNo, 0);                                
    delay(100);
  } 
}

void loop() 
{
  Blynk.run();
  timer.run();
  Blynk.virtualWrite(V10, targetDUS1);
  Blynk.virtualWrite(V12, targetDUS2);
}

You have delays everywhere and Blynk virtual writes in your void loop!!

The “keep your void loop clean“ article has been linked twice in this thread, but you don’t seem to have understood any of it.

Pete.

even with all the delay is erased and the Blynk Virtual write is placed under the void of USMe and USNo but still, no output on the blynk apps and my LED is not working/blinking without the delay


#define BLYNK_PRINT Serial1
#include <BlynkSimpleStream.h>
BlynkTimer timer;
char auth[] = "cabb6d95d9804956b25f9e4553fc10b8";


int GreenMe  =4 ;                                               
int YellowMe =3 ;                                               
int RedMe    =2 ;                                               

int EchoMe   =22 ;                                              
int TrigMe   =23 ;                                               
float pingUS1   ;                                              
float targetDUS1;                                               

                                                                
String GarbageCaps1me="The Garbage Capacity for Metal is 0%";   
String GarbageCaps2me="The Garbage Capacity for Metal is 50%"; 
String GarbageCaps3me="The Garbage Capacity is for Metal 100%";

                                                                 
int GreenNo  =10;                                               
int YellowNo =9;                                                                                          
int RedNo    =8;                                               

int EchoNo   =26;                                                
int TrigNo   =27;                                                 
float pingUS2;                                       
float targetDUS2;                                        
                                                                 
                                                                 
String GarbageCaps1no="The Garbage Capacity for Non-Metal is 0%";
String GarbageCaps2no="The Garbage Capacity is Non-Metal 50%";  
String GarbageCaps3no="The Garbage Capacity is Non-Metal 100%"; 

float speedOfSound=776.5;                                       
String GarbageLCD="Garbage Capacity";      

void setup() 
{
 Serial.begin(9600);
 Serial1.begin(9600);
 Blynk.begin(Serial, auth);

 pinMode(EchoMe, INPUT);
 pinMode(TrigMe, OUTPUT);
 pinMode(EchoNo, INPUT);
 pinMode(TrigNo, OUTPUT);
 timer.setInterval(1000L, USMe);
 timer.setInterval(1000L, USNo);
 
 
} 

void USMe()
{
  digitalWrite(TrigMe, LOW);                                  
  delayMicroseconds(100);                                       
  digitalWrite(TrigMe, HIGH);                               
  delayMicroseconds(20);                                       
  digitalWrite(TrigMe, LOW);                                  
  
  pingUS1 = pulseIn(EchoMe, HIGH);                          
  pingUS1 = pingUS1/1000000;                                 
  pingUS1 = pingUS1/3600;                                     
  targetDUS1 = speedOfSound*pingUS1;                    
  targetDUS1 = targetDUS1/2;                            
  targetDUS1 = targetDUS1*63360;                       
  targetDUS1 = targetDUS1*2.54;                         
  Serial.print("The distance to the trash is: ");             
  Serial.print(targetDUS1);                                
  Serial.println(" centimeters");                             
  Blynk.virtualWrite(V10, targetDUS1);                                               

  if (targetDUS1 < 10)                                     
  { 
    Serial.println(GarbageCaps3me);                           
    analogWrite(RedMe, 250);                                                              
                                                
    analogWrite(RedMe, 0);                                
   
  }
  
  if (targetDUS1 >= 11 && targetDUS1 <= 20)            
  {
    Serial.println(GarbageCaps2me);                                                             
    analogWrite(YellowMe, 250);                            
                                                
    analogWrite(YellowMe, 0);                            

  }
  
  if (targetDUS1 >20)                                    
  {  
    Serial.print(GarbageCaps1me);                           
    analogWrite(GreenMe, 250);                            
                                                 
    analogWrite(GreenMe, 0);                               
        
  }
}


void USNo()
{
  digitalWrite(TrigNo, LOW);                             
  delayMicroseconds(100);                                 
  digitalWrite(TrigNo, HIGH);                             
  delayMicroseconds(20);                                     
  digitalWrite(TrigNo, LOW);                             
  
  pingUS2 = pulseIn(EchoNo, HIGH);                           
  pingUS2 = pingUS2/1000000;                                 
  pingUS2 = pingUS2/3600;                                 
  targetDUS2 = speedOfSound*pingUS2;                   
  targetDUS2 = targetDUS2/2;                         
  targetDUS2 = targetDUS2*63360;                      
  targetDUS2 = targetDUS2*2.54;                         
  Serial.print("The distance to the trash is: ");             
  Serial.print(targetDUS2);                                
  Serial.println(" centimeters");                           
  Blynk.virtualWrite(V12, targetDUS2);

  
  if (targetDUS2 < 10)                              
  { 
    Serial.println(GarbageCaps3no);                  
    analogWrite(RedNo, 250);                      
                                  
    analogWrite(RedNo, 0);                                  

  }
  
  if (targetDUS2 >= 11 && targetDUS2 <= 20)           
  {
    Serial.println(GarbageCaps2no);                                                               
    analogWrite(YellowNo, 250);                             
                                  
    analogWrite(YellowNo, 0);                               
     
  }
  
  if (targetDUS2 >20)                                       
  {     
    Serial.print(GarbageCaps1no);                              
    analogWrite(GreenNo, 250);                              
                                                   
    analogWrite(GreenNo, 0);                                
 
  } 
}

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

Research a lots of coding and the way it works on the community such as

but still got the same results with no output on the blynk. if i erase all the delay for the LED, then how should i make the LED blinking. and I use 2 Gauge on the Blnyk Apps for Metal (V10) and Non Metal (V12) both is PUSH. My connection is USB type

#define BLYNK_PRINT Serial1
#include <BlynkSimpleStream.h>
BlynkTimer timer;
char auth[] = "cabb6d95d9804956b25f9e4553fc10b8";


int GreenMe  =4 ;                                               
int YellowMe =3 ;                                               
int RedMe    =2 ;                                               

int EchoMe   =38 ;                                              
int TrigMe   =39 ;                                               
float pingUS1   ;                                              
float targetDUS1;                                               

                                                                
String GarbageCaps1me="The Garbage Capacity for Metal is 0%";   
String GarbageCaps2me="The Garbage Capacity for Metal is 50%"; 
String GarbageCaps3me="The Garbage Capacity is for Metal 100%";

                                                                 
int GreenNo  =10;                                               
int YellowNo =9;                                                                                          
int RedNo    =8;                                               

int EchoNo   =44;                                                
int TrigNo   =45;                                                 
float pingUS2;                                       
float targetDUS2;                                        
                                                                 
                                                                 
String GarbageCaps1no="The Garbage Capacity for Non-Metal is 0%";
String GarbageCaps2no="The Garbage Capacity is Non-Metal 50%";  
String GarbageCaps3no="The Garbage Capacity is Non-Metal 100%"; 

float speedOfSound=776.5;                                       
String GarbageLCD="Garbage Capacity";      

void setup() 
{
 Serial.begin(9600);
 Serial1.begin(9600);
 Blynk.begin(Serial, auth);

 pinMode(EchoMe, INPUT);
 pinMode(TrigMe, OUTPUT);
 pinMode(EchoNo, INPUT);
 pinMode(TrigNo, OUTPUT);
 timer.setInterval(1000L, USMe);
 timer.setInterval(1000L, USNo);
 
} 

void USMe()
{
  digitalWrite(TrigMe, LOW);                                  
  delayMicroseconds(100);                                       
  digitalWrite(TrigMe, HIGH);                               
  delayMicroseconds(20);                                       
  digitalWrite(TrigMe, LOW);                                  
  
  pingUS1 = pulseIn(EchoMe, HIGH);                          
  pingUS1 = pingUS1/1000000;                                 
  pingUS1 = pingUS1/3600;                                     
  targetDUS1 = speedOfSound*pingUS1;                    
  targetDUS1 = targetDUS1/2;                            
  targetDUS1 = targetDUS1*63360;                       
  targetDUS1 = targetDUS1*2.54;                         
  Serial.print("The distance to the trash is: ");             
  Serial.print(targetDUS1);                                
  Serial.println(" centimeters");                             
  Blynk.virtualWrite(V10, targetDUS1);                                               

  if (targetDUS1 < 10)                                     
  { 
    Serial.println(GarbageCaps3me);                           
    analogWrite(RedMe, 250);                                                              
                                                
    analogWrite(RedMe, 0);                                
   
  }
  
  if (targetDUS1 >= 11 && targetDUS1 <= 20)            
  {
    Serial.println(GarbageCaps2me);                                                             
    analogWrite(YellowMe, 250);                            
                                                
    analogWrite(YellowMe, 0);                            

  }
  
  if (targetDUS1 >20)                                    
  {  
    Serial.print(GarbageCaps1me);                           
    analogWrite(GreenMe, 250);                            
                                                 
    analogWrite(GreenMe, 0);                               
        
  }
}


void USNo()
{
  digitalWrite(TrigNo, LOW);                             
  delayMicroseconds(100);                                 
  digitalWrite(TrigNo, HIGH);                             
  delayMicroseconds(20);                                     
  digitalWrite(TrigNo, LOW);                             
  
  pingUS2 = pulseIn(EchoNo, HIGH);                           
  pingUS2 = pingUS2/1000000;                                 
  pingUS2 = pingUS2/3600;                                 
  targetDUS2 = speedOfSound*pingUS2;                   
  targetDUS2 = targetDUS2/2;                         
  targetDUS2 = targetDUS2*63360;                      
  targetDUS2 = targetDUS2*2.54;                         
  Serial.print("The distance to the trash is: ");             
  Serial.print(targetDUS2);                                
  Serial.println(" centimeters");                           
  Blynk.virtualWrite(V12, targetDUS2);

  
  if (targetDUS2 < 10)                              
  { 
    Serial.println(GarbageCaps3no);                  
    analogWrite(RedNo, 250);                      
                                  
    analogWrite(RedNo, 0);                                  

  }
  
  if (targetDUS2 >= 11 && targetDUS2 <= 20)           
  {
    Serial.println(GarbageCaps2no);                                                               
    analogWrite(YellowNo, 250);                             
                                  
    analogWrite(YellowNo, 0);                               
     
  }
  
  if (targetDUS2 >20)                                       
  {     
    Serial.print(GarbageCaps1no);                              
    analogWrite(GreenNo, 250);                              
                                                   
    analogWrite(GreenNo, 0);                                
 
  } 
}

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

same timer, never works :stuck_out_tongue:

You use a timer, or a non-blocking utility like ticker, or you use a millis function and check how much time in millis has passed.

Pete.

meaning?

meaning that you can’t do two calls at the same time
try that

timer.setInterval(1000L, USMe);
timer.setInterval(1500L, USNo);

the millis function seems complicated to understand and to apply on my coding based on youtube on how to do the coding and is it the same as delayMicroseconds(x)?

as @Gunner always says :stuck_out_tongue: ,
you have to learn blynk before coding anything.
try basic blynk sketches to understand blynk timers,
there is a lot of examples on this community.