WEMOS D1 Mini to Microcontroller for Worm Drives

I have a setup I am attempting to code but if the Hardware is not designed for the usage, I may have to start from scratch.
My set up is a 12V DC power supply, which powers a L298n motor controller driving two Worm Drive DC motors.
I have opted to us a WEMOS D1 Mini powered by the 5v from the L298n. My inputs would be D1-D4 and my Outputs would be D5-D8.
D1 - D4 would be 4 Push Button Switches(INPUTS)
D5 - D8 would be 2 Motors with 2 directions (OUTPUTS) LOW and HIGH
My question is can D1 through D4 be used as switch inputs (10k Resistors attached)
And is there any prevention in using D5 - D8 for the OUTPUT signals directing the motors (HIGH, LOW) /(LOW,HIGH)?
My code calls it up as you would suspect, but without knowing the ability of the D1 Mini to handle the code
my fears are frying the chip due to the LOW or HIGH originating status's of the PINS.

Ive read several articles on using the PINS for specific tasks but when I get to the anatomy of the PINs I begin to get lost on my code. My code identifies the pins as high or low inputs on the closure of the switch but either the one motor runs continuously or the other motor does not respond.

My thought is that you cannot use 4 analog inputs on D1-D4. and I would have to use two WEMOS D1s to have my desired outcome. I have also looked at using the ESP32 but the same preset pins are causing more confusion.

Can anyone out there wade through my confusion here and point me in the right direction? Or should I just take up needlepoint. :disappointed_relieved:

I have attached a picture of something close to what I am trying to do. without the motors. I would simply use the led OUTPUTS in the picture with MOTORS. of course with 4 buttons.

I copied the chart below from: ESP8266 Pinout Reference: Which GPIO pins should you use? | Random Nerd Tutorials This will give you an idea of what you can do. Many of the pins have other uses other then general I/O especially at reset-boot time.
zin the WeMos D1, the pins are not independent as they are on the UNO. Several GPIOs are connected to two more points on the board. I could not post the picture but you can search for “WeMos D1 pinout” and get the drawing and schematic.

Label GPIO Input Output Notes
D0 GPIO16 no interrupt no PWM or I2C support HIGH at boot
used to wake up from deep sleep
D1 GPIO5 OK OK often used as SCL (I2C)
D2 GPIO4 OK OK often used as SDA (I2C)
D3 GPIO0 pulled up OK connected to FLASH button, boot fails if pulled LOW
D4 GPIO2 pulled up OK HIGH at boot
connected to on-board LED, boot fails if pulled LOW
D8 GPIO15 pulled to GND OK SPI (CS)
Boot fails if pulled HIGH
RX GPIO3 OK RX pin HIGH at boot
TX GPIO1 TX pin OK HIGH at boot
debug output at boot, boot fails if pulled LOW
A0 ADC0 Analog Input X

You can use D1 to D4 as inputs.
D1 and D2 are also for I2C, so by using them as inputs you lose I2C.
D3 and D4 must not be pulled low until boot has finished.

I don't understand your question about code.

In neither Fritzing diagram have the buttons been wired correctly.
It is usual to wire the button between the Arduino pin and ground. In the sketch, you explicitly switch on the button’s pull up resistor using the INPUT_PULLUP parameter of the pinMode() function. The Arduino pin, to which the button is connected, should never be allowed to float.

I thought you wanted D1 to D4 as inputs. If they are inputs you read them, you don’t write to them. Forget trying to write to inputs. Why have you got LEDs connected to the button inputs?

Follow 6v6gt’s instructions on wiring the buttons.

I have wrote them as Read - LSDin in one of the 4. LSDin = D2 then I identify LSDin as buttonStateLeftSideDown? I really don't know what you are referring to as what you stated. D1 through D4 are inputs. Unless you are speaking of how I hard wired it wrong.

In reply #4 you have buttons (so inputs) and LEDs (so outputs) connected to the same pins, this is all wrong. If you want D1 to D4 to be inputs for the buttons then you need to connect just buttons, not LEDs. Reply #5 tells you how to connect them.

There is a similar discussion here that might help you:

Look at how the buttons are connected in this

It's a Uno not a D1, but the idea is the same.

You are still mixing up buttons and LEDs.

So to be clear, do you want an LED to light when you press the button, and only while you hold the button? Have I understood correctly?


Wire the buttons between ground and the pin as per the the other discussion I linked to.

Connect an LED cathode to the junction of the pin and the pin. Connect a resistor of about 220Ohms between the LED anode and +5V.

Show your schematic so we can comment.

That looks good.
Use INPUT_PULLUP when for setting up the pins.

Make sure you put the buttons in the bread board the right way.

What happened to your replies in here, it looks like you deleted many of them.

Doing that is considered vandalism, it makes a mess of the topic and means it no longer makes sense to anyone reading it. Please can you leave your replies in place for your other questions? The answers you get are not just for you, they are for anyone else reading this who has a similar problem.


This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.