Understand GPIO.write

  1. My goal is: I want to know about GPIO.write states
  2. My actions are:
load('api_gpio.js');

GPIO.set_mode(2, GPIO.MODE_OUTPUT);
GPIO.write(2,1);

I am testing GPIO functionality with LoLin ESP 8266 board
when I use GPIO.write(2,0) on board led is on and when I use GPIO.write(2,1) led is off.
3. The result I see is:
I am testing GPIO functionality with LoLin ESP 8266 board
when I use GPIO.write(2,0) on board led is on and when I use GPIO.write(2,1) led is off.
4. My expectation & question is:
In general 1 stands for HIGH i.e. led should be on and 0 stands for low i.e. off.
please help I need to present my work tomorrow.

Maybe the led needs a 0 to be lit. Check yours board’s schematic diagram.

This is a convention that goes back to the days when such interface ICs were made from TTL instead of CMOS technology. With TTL, a channel being high used less power, and TTL used a lot of power. With CMOS it makes no difference but the convention stuck. Some chips allow you to invert this, but you can easily do it in your code with an !.

1 Like

I achieved it using negation operator only but I just want to confirm. I thought that I am wrong somewhere.Thanks for explanation.