Go Down

Topic: WEMOS D1 Mini to Microcontroller for Worm Drives (Read 229 times) previous topic - next topic

nptt13

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.  :smiley-sad-blue:


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.


gilshultz

#1
Feb 22, 2021, 10:36 pm Last Edit: Feb 22, 2021, 10:45 pm by gilshultz
I copied the chart below from: https://randomnerdtutorials.com/esp8266-pinout-reference-gpios/ 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.

LabelGPIOInputOutputNotes
D0GPIO16no interruptno PWM or I2C supportHIGH at boot
used to wake up from deep sleep
D1GPIO5OKOKoften used as SCL (I2C)
D2GPIO4OKOKoften used as SDA (I2C)
D3GPIO0pulled upOKconnected to FLASH button, boot fails if pulled LOW
D4GPIO2pulled upOKHIGH at boot
connected to on-board LED, boot fails if pulled LOW
D5GPIO14OKOKSPI (SCLK)
D6GPIO12OKOKSPI (MISO)
D7GPIO13OKOKSPI (MOSI)
D8GPIO15pulled to GNDOKSPI (CS)
Boot fails if pulled HIGH
RXGPIO3OKRX pinHIGH at boot
TXGPIO1TX pinOKHIGH at boot
debug output at boot, boot fails if pulled LOW
A0ADC0Analog InputX

This response is to help you get started in solving your problem, not solve it for you.
Good Luck & Have Fun!
Gil

PerryBebbington

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.

6v6gt

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.

PerryBebbington

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.

PerryBebbington

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:
https://forum.arduino.cc/index.php?topic=729229.new;topicseen#new

PerryBebbington

Look at how the buttons are connected in this
https://forum.arduino.cc/index.php?topic=729229.msg4905764#msg4905764
It's a Uno not a D1, but the idea is the same.

You are still mixing up buttons and LEDs.

PerryBebbington

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?

PerryBebbington

Right.

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.

PerryBebbington

#9
Feb 23, 2021, 11:31 pm Last Edit: Feb 23, 2021, 11:33 pm by PerryBebbington
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.

PerryBebbington

nptt13
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.

Thanks.

Go Up