BLYNK
BLYNK.IO       📲 GETTING STARTED       đź“— DOCS       âť“HELP CENTER       👉 SKETCH BUILDER

Selector switch

Have a nice day

I need to control old fan it has selector switch , When one switch is pressed (ON) another switch released ( OFF)

I need four selector switch

Can Blynk app has such switch

Please advice

You could use a Segmented Switch widget, or you could make your own using four Button or Styled Button widgets and handle the logic with some simple code.

Pete.

Dear Pete Thanks for the reply

I think Segmented Switch maybe suitable

Dayan

Yes… My first step is succeed by the help of Pete

Now I need to turn OFF the Fan withing 30 minutes and turn ON again 30 minutes and so on
How should I combine Segmented switch and timer
Please advice

Search this forum for “Timeout Timer” and you’ll see some examples.

Pete.

I tried but could not find the such information

long variableTime = 1000; // default interval time of 1 second
int varTimer;  // Setup Timeout Timer ID 
BLYNK_WRITE(V0) { // Widget for interval timing
  variableTime = param.asInt();
  if (variableTime <= 0) { // prevents a timer from becoming 0 or less
    variableTime = 1;
  }
  timerLoop();  // Call your timed loop
}



void timerLoop() {
  timer.deleteTimer(varTimer);  // Cancel previous Timeout Timer
  //  
  //  Do your stuff here every (variableTime) seconds
  //
  varTimer = timer.setTimeout(variableTime, timerLoop);  // Set new Timeout timer
}

By @Gunner

1 Like