Led widget Raspberry Pi 3 (Node.js)

sorry, i want to read the gpio 26, if it is high must turn on the led widget, if it is low it must turn off the led widget. consider it as if the raspberry received an error signal on gpio26 and you should turn on the led v1 widget

You have used the reference GPIO 24, 25 and 26 in this thread.
Which one is it and are you saying you can’t make the code do what you want (v1 ON if high and OFF if low)?

When i press the button as in the drawing, turn on the led widget.
I do not know how to explain it

Yes I understand but I was confused by your references to GPIO 24, GPIO 25 and GPIO 26.

So we can ignore all GPIO references except GPIO 26.

yes

 ************************************************** ***********
  Blynk usando un widget LED sul tuo cellulare!
  Impostazione progetto di un'applicazione:
    Widget LED su V3
************************************************** ********** * /

/ * Commenta questo per disabilitare le stampe e risparmiare spazio * /
# define  BLYNK_PRINT Seriale


# include  < SPI.h >
# include  < Ethernet.h >
# include  < BlynkSimpleEthernet.h >

// Dovresti ottenere l'Auth Token nell'applicazione Blynk.
// Vai alle impostazioni del progetto (dado della noce).
char auth [] = " YourAuthToken " ;

// Seleziona il tuo perno con il pulsante fisico
const  int btnPin = 1 ;

WidgetLED led3 (V3);

Timer BlynkTimer;

// V3 LED Widget rappresenta lo stato del pulsante fisico
boolean btnState = falso ;
void  buttonLedWidget ()
{
  // Pulsante di lettura
  boolean IsPressed = ( digitalRead (btnPin) == LOW);

  // Se lo stato è cambiato ...
  se (isPressed! = btnState) {
    se (isPressed) {
      LED3. su ();
    } else {
      LED3. off ();
    }
    btnState = isPressed;
  }
}

void  setup ()
{
  // Console di debug
  Seriale. iniziare ( 9600 );

  Blynk. iniziare (auth);

  // Impostazione del pulsante del pulsante fisico (basso attivo)
  pinMode (btnPin, INPUT_PULLUP);

  Timer. setInterval ( 500L , buttonLedWidget);
}

void  loop ()
{
  Blynk. eseguire ();
  Timer. eseguire ();
}

@Costas
Looks by turning on the net I found this sketch but it does not work. should replace const int btnPin = 1;
in to gpio26 how do I do it?

@Jack1 the sketch you have found is C++ code and normally used on Arduino’s / ESP’s etc.
I created a post quite some time ago about compiling C++ “Arduino” sketches for use on the Pi but to be honest it’s probably easier to learn a bit more nodejs.

how do I make this sketch? I no longer know where to blink my head

As it’s a simple sketch I could probably provide the link for compiling C++ to use on a Pi but is this all you really want to do with Blynk?

If the answer is yes I’ll dig out the link but if you want to build a real project then C++ on the Pi is only for experienced coders who know their way around libraries etc.

My Pi’s are a bit preoccupied at present but I could probably find time to knock up the nodejs sketch if nobody else offers to do it.

Yes. I need to figure out whether an irrigation pump starts correctly or not. I need this project. Thanks for your help

@Jack1 the details provided by @Gunner should provide all you need. I ran some of the code on one of my Pi’s today and it was fine. I might need to tweak it a little for you but first paste what you get from:

gpio readall

yes, the gunner works well, but uses 2 gpio to work. the string | led = new Gpio (18, ‘out’) | I do not need it . I’m trying to figure out how to remove it and make it work the same

Do you just want Blynk LED’s or physical LED’s as well?

I just want Blynk led

Physical led :-1: NO

Then the end of the script just needs to look something like this:

button = new Gpio(12, 'in', 'both');  // Sets up the BCM pin 12 as an input registering both rising and falling for the variable "button", BCM 12 is GPIO 26 and physical pin 32

button.watch(function (err, value) {  // Watches for button press and assigns 0/1 to value
	if (err) {
		throw err;  // Some form of error handling
		console.log('GPIO26 button error');
	}
console.log('GPIO26 button changed');
	if (value  == 0) {
		console.log('GPIO26 OFF');
		blynk.virtualWrite(23, 0);    // V23 Widget (Green) LED off
		blynk.virtualWrite(22, 255);  // V22 Widget (RED)   LED on
	} 	
	else if (value == 1) {
		console.log('GPIO26 ON');
		blynk.virtualWrite(23, 255);  // V23 Widget (Green) LED on
		blynk.virtualWrite(22, 0);    // V22 Widget (RED)   LED off
	}
}); 

button = new Gpio(26, ‘in’, ‘both’); // Sets up the BCM pin 12 as an input registering both rising and falling for the variable “button”, BCM 12 is GPIO 26 and physical pin 32

button.watch(function (err, value) { // Watches for button press and assigns 0/1 to value
if (err) {
throw err; // Some form of error handling
console.log(‘GPIO26 button error’);
}
console.log(‘GPIO26 button changed’);
if (value == 0) {
console.log(‘GPIO26 OFF’);
blynk.virtualWrite(1, 0); // V23 Widget (Green) LED off
blynk.virtualWrite(2, 255); // V22 Widget (RED) LED on
}
else if (value == 1) {
console.log(‘GPIO26 ON’);
blynk.virtualWrite(1, 255); // V23 Widget (Green) LED on
blynk.virtualWrite(2, 0); // V22 Widget (RED) LED off
}
});

@Jack1 yes that’s a copy of what I posted 3 hours ago. What about it?