Invert dashboard button operation


I’m using a button on the dashboard to turn on/off the inbuilt LED on a NodeMCU 8266.

Slight problem is that switch operation is inverted i.e. when switch is on LED is off and vice versa.

I have done a simple work around by colouring the button so that ‘on’ is a dark colour and ‘off’ is a light colour’. Would be nice though if button worked same as LED.

Have tried various methods in my code but the thinger dashboard button function obviously looks at the state of the built in LED pin on the 8288 and I can’t work out how to change it

I’m currently using the following code in the 8266 to control the LED;

thing[“led”] << digitalPin(LED_BUILTIN);

Here are things I’ve tried to invert the operation, all of which only momentarily change the state of the LED and the dashboard button reverts to its original state.

thing[“led”] << [](pson& in){
in = (bool) digitalRead(LED_BUILTIN);
//digitalWrite(LED_BUILTIN, in ? HIGH : LOW);
digitalWrite(LED_BUILTIN, !in);


Please post your code as preformated text, select code text and press the “</>” button in the menu.

Try defining the input as:

thing[“led”] << invertedDigitalPin(LED_BUILTIN);

Hope this helps.

Hi Ega

You are a star:-) That works perfectly.

I had tried ‘invert’ before but obviously it needed to be ‘inverted’

Many thanks for such a prompt response.