Hello,
i think the question is maybie trivial, but I'm an "arduino beginner" ..
Hardware:Arduino UNO
For my project i have a component, where i have to switch 4 different pins on a component to the GND-PIN on my arduino, when in need.
I know i could use transistors in my circuit, to switch them to the GND, but i think there is a smarter (software-only-solution) for my problem...
Connect one side of each switch to a different Arduino pin. Connect the other side of the switches to GND. To ensure that the pins are always at a known state use INPUT_PULLUP as the second parameter in pinMode() for each pin
Now when a switch is closed you can detect that the pin has gone LOW using digitalRead()
crackjack:
For my project i have a component, where i have to switch 4 different pins on a component to the GND-PIN on my arduino, when in need.
We really need to know what the "component" is, most of the replies are assuming that you are referring to a physical switch (ON/OFF switch of some type), but your description sounds like you may be referring to something completely different.
Yeah you're right..
I think my bad explenation was completely misleading.. Sorry next time i give a full description.
The component is a 7-Segment display, with 4 numbers (Model: 5461AS) i wanted multiplexing the Numbers (GND, HIGH, GND, HIGH....).
I feel stupid now, I fixed it with the simple command digitalWrite(pin, LOW), when in need, like Mr. alesam told me.
But i learned sth. . I thought digitalWrite(pin, LOW), just gives 0V as a output-voltage... now i know it is connecting my pin to the ground (very helpful for the future).
crackjack:
But i learned sth. . I thought digitalWrite(pin, LOW), just gives 0V as a output-voltage... now i know it is connecting my pin to the ground (very helpful for the future).
The problem is - it's not generally true. Although it does "connect the pin to ground", a HIGH on a pin does not do the opposite, disconnect the pin. It also connects the pin to Vcc. So in many applications, you can not use a digital output as a simple switch. The classic "switch to ground" is an "open collector" output, which has no voltage at the output in the HIGH state. The Arduino doesn't have any of those. Even that won't work under all circumstances, the applied voltage must be of a certain polarity and limited to a certain maximum. Additionally, the impedance (resistance) of a digital output is far greater than most switches, severely limiting the current that it can effectively switch when it is used for that purpose. The second problem is what makes it problematic when driving a LED matrix. Thus your idea of using transistors there is a good one.