Delay speed

Hello

How can I make delay speed because blynk with the slider has no analog pins

I want to take the code

int sensorPin = A0;    // Analog input pin to pot
int ledPin = 7;      // PWM pin to LED
int sensorValue = 0;  // variable to store pot value

void setup() {
  // declare the ledPin as an OUTPUT:
  pinMode(ledPin, OUTPUT);  
}

void loop() {
  // read the value from the sensor:
  sensorValue = analogRead(sensorPin);    
  // turn the ledPin on
  digitalWrite(ledPin, HIGH);  
  // stop the program for <sensorValue> milliseconds:
  delay(sensorValue);          
  // turn the ledPin off:        
  digitalWrite(ledPin, LOW);   
  // stop the program for for <sensorValue> milliseconds:
  delay(sensorValue);

Slider, virtual pins and SimpleTimer.

thank you Costas

my code :slight_smile:

#include <SoftwareSerial.h>
SoftwareSerial DebugSerial(2, 3);
int LED = 3;
int LED1 = 5;
int LED2 = 6;
int LEDspeed;
#define BLYNK_PRINT DebugSerial
#include <BlynkSimpleStream.h>
 #include <SimpleTimer.h>
char auth[] = "8e673cec3da9d6e4ccf1";

 SimpleTimer timer;

 BLYNK_WRITE(V8){

  LEDspeed = (param.asInt());
}
 void setup()
{
   DebugSerial.begin(9600);
   timer.setInterval(LEDspeed, test);
  Serial.begin(9600);
  Blynk.begin(Serial, auth);
  
  pinMode(LED, OUTPUT);
  pinMode(LED1, OUTPUT);
  pinMode(LED2, OUTPUT);
  
}

void test() {
  // read the value from the sensor:
     
  // turn the ledPin on
  digitalWrite(LED, HIGH);  
   digitalWrite(LED1, LOW);
    digitalWrite(LED2, LOW);
  delay(LEDspeed);          
      
  digitalWrite(LED, LOW);   
  digitalWrite(LED1, HIGH);
  digitalWrite(LED2, LOW);
  delay(LEDspeed);
  
  digitalWrite(LED, LOW);   
  digitalWrite(LED1, LOW);
  digitalWrite(LED2, HIGH);
  delay(LEDspeed);
}  
void loop()
{
  Blynk.run();
  timer.run();
}
 

@markop now that you have published your security token you should refresh it in the app and on the hardware.

Is your sketch working OK?

@Costas Hello
The security token is not completely missing.
The sketch works perfectly

1 Like