0

I am setting up a page on NodeMCU running as a web server and I want to be able to turn on and off a light based on the url being clicked.

I want to know how I can get the status so that I can set the URL based on the pin status as well as pass the GPIO pin status in the JSON from the NodeMCU web server.

The code is here.

closed as too broad by jfpoilpret, Code Gorilla, gre_gor, KIIV, Avamander Apr 10 '17 at 23:46

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

1

Independent of the setting of port direction (input or output), pin can be read through the digitalRead():

int pin_light = 3;
int status = digitalRead(pin_light);
  • The OP said he has a NodeMCU board. Those runs Lua code. Your example seems to be C-code and would not work on a NodeMCU unless you "reflash" it to standard Arduino C-code. Reading a pin on NodeMCU should be gpio.read(PIN) – Daniele Testa Sep 15 '18 at 6:27
  • The OP said he has a NodeMCU board. Those runs Lua code. Your example seems to be C-code and would not work on a NodeMCU unless you "reflash" it to standard Arduino C-code. Reading a pin on NodeMCU should be gpio.read(PIN) – Daniele Testa Sep 15 '18 at 6:28
  • You are rigth, but question refers an example with code and C and it is tagged with C :blink: – caligari Sep 16 '18 at 11:01

Not the answer you're looking for? Browse other questions tagged or ask your own question.