Using > 127 Virtual Pins in sketch

The BLYNK_WRITE_DEFAULT() function handle virtual write for all pins > 127, this is a small example to manage pins 181 and 190:

BLYNK_WRITE_DEFAULT()
{
  int pin = request.pin;      // Which pin has trigger write
  int value = param.asInt();  // Use param as usual.

  //only for debug
  Serial.print("virtual write pin: ");
  Serial.print(pin);
  Serial.print(" value: ");
  Serial.println(value);

  //handle pins actions
  switch(pin){
    case 181:
      //your custom code for pin 181
      Serial.println("TODO 181");
      break;
      
    case 190:
      //your custom code for pin 190
      Serial.println("TODO 190");
      break;
   }
}

Best Regards

4 Likes