Hi guys. I have a question. Should I connect a button like this? Is it safe for other modules and for the Arduino? The button works in serial Can you help me with this issue, please?
Why would you wire the switch that way?
Because I have other modules which connect to Arduino Nano and all GND aren't available they've already connected. I need to wire one button but it's the only way that I can do.
You just need a splitter for the ground connections, no need to bodge some strange circuit arrangement. For instance its typically assumed you are using a breadboard to prototype so the ground strip on the breadboard provides dozens of ground connections if needed.
Sometimes a miniature breadboard is useful purely for ground and power distribution for this reason, or you can solder some hook-up wires together to make a little harness for ground/power distribution.
There is a ground available on the ICSP connector.
- What if I connect that way (in that screenshot)
- What if I connect two modules in ONLY ONE ground by soldering them in one ground? (Will it be safe for Arduino and modules?)
I can't wire there because there is a module that has already been wired there. (Arduino nano) Oh. I don't really know what to do.
In a pinch you can wire the switch like in your diagram in the original post. Set one pin to output and write it LOW. Set the other to INPUT_PULLUP. When you read the input, the input will be HIGH for a switch that is not pressed and LOW for the pressed switch. Like this, try it,
const byte groundPin = 11;
const byte switchPin = 12;
void setup()
{
Serial.begin(115200);
pinMode(switchPin, INPUT_PULLUP);
pinMode(groundPin, OUTPUT);
digitalWrite(groundPin, LOW);
}
void loop()
{
Serial.println(digitalRead(switchPin));
delay(500);
}
That will be OK. Ground is ground. All of the ground pins are connected together.
You really haven't ever made anything electrical before, have you?
Hi. What's the problem? I'm a newbie in all this electrical stuff
Thanks for your reply! I'll try. I just needed to make sure that the first option would be safe.
Quite clearly. That's just the point, it's just how it shows.
If you had the experience of most of us "old timers", wiring together power supplies, batteries, lights, switches and other stuff, or model railways for example, you would of course, not be asking these questions.
Hello Sierrra1
You have bit to learn about electrics/electronics I have been at for almost 70 years, a man next door was amateur radio enthusiast and got me going when i was six years old . I hope you find such a good electronics buddy, plus there is this forum and lots of help here. Ground is Ground is Ground, so just make up some type of Y wire cable to give you the Ground for one end of your switch. The other end of your switch goes to the input port you intend to use, you can use the port in digital or analogue mode, the general convention is to use the port in digital mode. Then you need to pull the Switch/Input Pin to 5V this can be done with a resistor pretty much anything from 1k to 10k or more will be fine.
Or some Digital input ports can have an internal Pull Resistor that you turn on like so from software pinMode(2, INPUT_PULLUP);
Hope that helps imk
PS the solution above of using one digital output port to drag one end of the switch low is ok but it is not Ground. It will work but not ground only close to it. But it is a very useful technique if you have MORE switches than inputs as you can create a matrix of switches and then use some digital pins to pull a row/column low/ground with a scanning technique. This is bit beyond you i think now but bare it in mind for a future learning experience
PPS One final word on Ground is, it is worth reading up on the subject with respect to Ground loops that can be most troublesome at times particularly in analogue/audio circuits as they can lead to noise
Hello Sierrra1
One last word, for electronics help it might be worth while checking to see if you have a local electronics/amateur radio club or a local HackSpace or MakerSpace as i am sure you would find so electronics help there. imk
The Arduino designers didn't provide enough ground and power pins. That is why a lot of clones added them. One thing I've sometimes done, taken a row of header pins and soldered the short ends together. That makes a Dupont wire "junction strip". I can connect multiple grounds to it.
Hi! Thanks for your reply! I appreciate your answer
I'm glad that there are people that can help with different situations especially those topics that I'm not good at
I'm grateful to you. Thanks.
Also i have a breadboard attached to my uno like in photo then you have TWO ground rails plus TWO Plus rails, one can be 3.3 other 5v with lots of space for switches and other sensors, LCDs etc.
Be mindful of the breadboard some have 5 skts per column other 6 skts per column.
Six is better when you use board like NANO. Also something like this shield may really help as switches and LCD to display the ultrasonic range etc
If you are using a Nano then these https://www.ebay.co.uk/itm/331928690895?hash=item4d487de0cf:g:g5cAAOSwAGlZzHkx are very handy. A GND and 5V pin for each and every IO pin on the Nano
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.