BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Pinled high

Hi, I’ve been trying to make my pinled output high for several days because my relay is reverse technology, it needs VCC output
and investigated examples but I get nothing, I am using the example of botonphysical blyn.
Some programmer of blynk could help me thanks.

I tried changing
int ledState = LOW; BY int ledState = HIGH;
the relay follows LOW

I have also introduced
digitalWrite(ledpin, HIGH);
without getting anything



#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "xxxxxx";
char pass[] = "xxxxxxx";


// Set your LED and physical button pins here
const int ledPin = 4;
const int btnPin = 5;

BlynkTimer timer;
void checkPhysicalButton();

int ledState = LOW;
int btnState = HIGH;

// Every time we connect to the cloud...
BLYNK_CONNECTED() {
  // Request the latest state from the server
  //Blynk.syncVirtual(V2);

  // Alternatively, you could override server state using:
  Blynk.virtualWrite(V2, ledState);
}

// When App button is pushed - switch the state
BLYNK_WRITE(V2) {
  ledState = param.asInt();
  digitalWrite(ledPin, ledState);
}

void checkPhysicalButton()
{
  if (digitalRead(btnPin) == LOW) {
    // btnState is used to avoid sequential toggles
    if (btnState != LOW) {

      // Toggle LED state
      ledState = !ledState;
      digitalWrite(ledPin, ledState);

      // Update Button Widget
      Blynk.virtualWrite(V2, ledState);
    }
    btnState = LOW;
  } else {
    btnState = HIGH;
  }
}

void setup()
{
  // Debug console
  Serial.begin(9600);

  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);

  pinMode(ledPin, OUTPUT);
  pinMode(btnPin, INPUT_PULLUP);
  digitalWrite(ledPin, ledState);
  

  // Setup a function to be called every 100 ms
  timer.setInterval(100L, checkPhysicalButton);
}

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

This is the documentation for the LED widget:

You’ll see that using a virtualWrite command of 0 will turn it off, and 255 will turn it on to maximum brightness.

In the C++ programming language, LOW or false = 0 and HIGH or true = 1

This means that you are actually turning the LED widget on, but at brightness level 1 out of 255, so it’s so dim that you won’t be able to tell that it’s on unless you look st it very closely.

Pete.

thanks pete for your valuable advice, but it was not possible to get the VCC input relay to work.
Already awakened by the investigation I decided to try the Arduino motherboard one and my surprise works correctly I can work with both VCC and 0 relays, only by changing the 1-0 and 0-1 button in the app.