1 GPIO pin on esp8266 for some Physical Button and set up some LEDs?

Can I use 1 GPIO pin on esp8266 for some Physical Button and set up some LEDs?

for me the answer is yes but it is up to your knowledge about the electronic. Should you search further within this community as I am sure someone has done. A tip for you it is about the ADC pin that you need to design a schematic to feed it…obviously a code to be along. Hope this helps.

Yes (I assume you mean one GPIO pin for the physical button and one GPIO pin for each of the LED’s).

I’m not sure which “flavor” of ESP8266 you’re using. There are 20 different ESP8266 modules. Different developments boards (e.g., NodeMCU, Wemos D1 Mini, …) leverage different modules. The answer to your question doesn’t change depending on the board / module you use, however, if you need additional help, we’d benefit from knowing which board / module you’re using.

And you don’t need to use the ESP8266 ADC pin to monitor a physical button or control LED’s.

Joe

1 Like

@wickedbeernut: it seems he took various experiments that he knew the number of pins limited. For boards you mentioned they are really the same “flavor” since they are all generic 8266 based.

@projecttrinof: I forgot to answer you from my previous post. Yes in case you use physical button to trigger, it depends what level you use H or L then we can indicate the LED syned realtime to the button. Technically it is pull up / down in your schematic and again it needs to do some additional electronic components.

Here I use NodeMCU V3 from Lolin

I want to use 5 physical buttons with 1 Pin GPIO and Want to Control 5 LEDs with 5 GPIO

its possible.
If you want to tell the difference between the 5 buttons, you could probably place a different resistor in series with each and measure the voltage on the analog pin.
All this can be done without Blynk also.

1 Like

thank you for responding to my question, we are narrowing down here that I want to use Blynk, because this forum is Blynk.

@projecttrinof: so you could try with ADC pin as long as you can design and build a divider with resistors to feed ADC. According to the esp8266 spec, the ADC pin could be fed from 0 - 1 (V) but the output is read from it 0 - 1024. You could get further from Github here https://github.com/RandomHacksYoutube/ESP8266-5-Relays/blob/master/FiveRelaysRemoteOrLocalControl.ino where it has some video along. Hope this helps.

I hope you tried it and me too. From various experiments I saw it is not easy … and the code is the key … you think so … dont you? :slight_smile:

Personally, I’d attach the buttons to the 5 digital pins, then multiplex the output of another pin to drive the LEDs.

Or use an ESP33.

Pete.

ESP32?

1 Like

Yes, typo from me!

Pete.

Damn, I thought maybe I’d missed some next-generation, whiz-bang microcontroller.

An ESP32-based development board would certainly be the cleanest solution. I use a HelTec ESP32 Wi-fi Kit. It comes with a cute little onboard 0.96" OLED.

1 Like

Yes that way is another one solution but it uses number of pins depending on how many outputs you want to be, eg 2 pins can create 4 physical buttons, 3 pins for 8 buttons and so on. Besides, we need much additional components against to the adc pin solution so it is costly issue.

the adc pin solution is using only one pin itself to be fed by resistors divider schematic seems the easiest way since you can simply add in more just resistors upon how many buttons you want. The rest job is the code and this is the most interesting part :grinning:

@projecttrinof started off talking about a physical button and “some” LED’s. Then we found out it was actually five physical buttons and five LED’s (that’s well-suited for an ESP32). If we’re now talking about eight buttons and who knows how many LED’s, sure … let’s pursue a different solution.

@dunghnguyen
@wickedbeernut
@PeteKnight
@DaleSchultz

thank you all, I have tried to answer the answers from @dunghnguyen and agreed to add electronic components and complete the schema and make a simple code that I took an example from the internet. now I find things that I don’t understand, that is, with the button (button momentarily) led just turning on the button that is pressed. then how do you make the led light when the button is pressed once and turn off when the button is pressed again

Check out this example. .
https://examples.blynk.cc/?board=ESP8266&shield=ESP8266%20WiFi&example=More%2FSync%2FSyncPhysicalButton

Just add in the additional pins that the other leds are connected to. Multiple buttons could be wired in parallel, although you will not be able to identify which button is pressed. Also, if you push one button to turn on the led, pressing any or the same button would turn it off.

If you want the leds to come on at different times, then the example provided will need to be modified a bit.

Hahaha sorry my friend if I perhaps made you confused … anyway from the topic subject I suppose you know fundamental electronic so you asked. Now it seems you should start to know a bit from the basic how to turn a LED on / off before going further. OK for a led on you press a pin to trigger another pin the one connecting to power a LED up. Then when you want to blow it off (like a candle haha) you also press the same button but in that case we just swap the stage of the led pin.

I talk too much … you could get the best from here https://www.arduino.cc/en/Tutorial/Blink

Then you could continue with Blynk here https://examples.blynk.cc/?board=ESP8266&shield=ESP8266%20WiFi&example=More%2FSync%2FSyncPhysicalButton

@Toro_Blacno, @dunghnguyen sorry according to my understanding and I have implemented, my code and scematic works like a switch not like a momentary button. so the LED will continue continuously if the button is pressed without removing the press, and the LED turns off when I don’t press the button.