Arduino Forum

Using Arduino => Microcontrollers => Topic started by: Mutabor on May 11, 2016, 11:19 am

Title: digitalWrite HIGH & LOW inverted (SOLVED)
Post by: Mutabor on May 11, 2016, 11:19 am
Hello!

I bought the following board:
http://www.aliexpress.com/item/Free-shipping-NodeMCU-development-board-for-ESP-12E-from-ESP8266-esp-12E-Lua-IoT-programable-wifi/32583355412.html (http://www.aliexpress.com/item/Free-shipping-NodeMCU-development-board-for-ESP-12E-from-ESP8266-esp-12E-Lua-IoT-programable-wifi/32583355412.html)

(http://g02.a.alicdn.com/kf/HTB1HbKNLXXXXXc0XpXXq6xXFXXXs/Free-shipping-NodeMCU-development-board-for-ESP-12E-from-ESP8266-esp-12E-Lua-IoT-programable-wifi.jpg)


I use the Arduino IDE, and everything works pretty much fine. I only have one problem:
If i test it for the blink sketch it reads HIGH as LOW and LOW as HIGH.

Example:
Code: [Select]

void setup() {
// initialize digital pin 16 as an output.
pinMode(16, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
digitalWrite(16, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(16, LOW); // turn the LED off by making the voltage LOW
delay(100); // wait for 1/10 second
}


This should do (as far as i know) that the LED is on for 1 second and then have a short pause of 1/10 second.
But what the board is really making is the opposite. The LED is off for 1 second following a short blink 1/10 second and so on...
Am I insane or is this plain inverted?

I'm on a mac with Arduino IDE 1.6.8
I use the following bridge drivers:
https://www.silabs.com/products/mcu/Pages/USBtoUARTBridgeVCPDrivers.aspx

Thank you for answers!
Title: Re: digitalWrite HIGH & LOW inverted
Post by: graynomad on May 11, 2016, 12:09 pm
Do you have a schematic? Maybe the LED is connected to VCC and not GND.
Title: Re: digitalWrite HIGH & LOW inverted
Post by: Riva on May 11, 2016, 01:19 pm
If the NodeMCU is using the same schematic as the below then yes the LED is inverted and will be on when pin is low and off when pin is high.

(https://raw.githubusercontent.com/nodemcu/nodemcu-devkit/master/Documents/NODEMCU_DEVKIT_SCH.png)
Title: Re: digitalWrite HIGH & LOW inverted (SOLVED)
Post by: Mutabor on May 12, 2016, 02:10 pm
Thank you so much! It works!

I was so excited over the new board I only tested the onboard LED.
The fact that it worked exactly inverted confused me a lot, I thought it is a hardware problem.

I really appreciate your help!
Title: Re: digitalWrite HIGH & LOW inverted (SOLVED)
Post by: GiovanniBernal on Aug 11, 2018, 11:14 pm
I got the same problem, so just to know, In ES8266 when you rite LOW(at least in the built in led) it goes on Right?