Wiring an ON-OFF-ON Momentary Toggle Switch (6 pin) "CHILY 7026"

I have Digital ports 1 and 0 on my UNO both set to look for a "HIGH" signal. When port 1 reads "HIGH", a variable is to decrement. When 0 reads "HIGH", the same variable is to increment. The wiring I currently have (see below) worked when testing two DC motors as the outputs, but isn't working when wired to the Arduino.

1 - Digital pin 1 on UNO
2 - Power (5V)
3 - Digital pin 0 on UNO
4 - Nothing
5 - Ground
6 - Nothing

What would the correct wiring be for my situation? Thanks!

Correct wiring for what? What are the motors?

The motors aren’t part of the intended usage, I simply used them to test. What i am trying to do is wire the switch so that the “left” position sends power to “output 1” and the “right” position sends power to “output 2”. Basically just “ON” in either direction, but to different outputs.

Wire the switch with Common to Gnd, NO to one input, NC to the other.
Use the internal pullup resistor on both inputs.
When the switch is to one side, one pin is grounded (LOW) and the other is pulled up to 5V (HIGH), and vise versa.
You only need a SPDT switch, not a DPDT switch. If you have a DPDT, you can use just one side of it.

CrossRoads:
You only need a SPDT switch, not a DPDT switch. If you have a DPDT, you can use just one side of it.

Was beginning to suspect that...shit! lol
Alright, thanks! :slight_smile:

Actually, would you be able to provide a diagram of your described wiring, please? Plus, I'm not sure how to use the internal pullup resistors of the Arduino since I'm very new.

EDIT/UPDATE: Managed to get it working actually lol. I'm using all 6 pins (not sure if they're all actually doing something, but...), and I've changed the code to act if there is a LOW detected on either pin instead of a HIGH.

Current wiring (visual):
GND 5V

"Data" "Data"

5V GND

Chily 7026

Switches like these (high power) usually have a minimum switching current to work reliably. When switching low level DC, I would suggest that the switch's contacts see greater than 1mA DC, so using internal pullup resistors isn't a good idea.

Some strong external1K pullups should work great. Also, its good that the switch is (ON) OFF (ON) which means it always returns to the center OFF position ... there'll be current draw through the pullups when not used. You can also connect it in such a way that no debouncing is required.

Here's a suggested circuit and code to get you started ...

If you use something like this in your code, you can read the input pins bounce free:

if (!digitalRead(dataA) && digitalRead(dataB)) {
  // dataA is switched low
}
if (!digitalRead(dataB) && digitalRead(dataA)) {
  // dataB is switched low
}

dlloyd:
Chily 7026

Switches like these (high power) usually have a minimum switching current to work reliably. When switching low level DC, I would suggest that the switch's contacts see greater than 1mA DC, so using internal pullup resistors isn't a good idea.

Some strong external1K pullups should work great. Also, its good that the switch is (ON) OFF (ON) which means it always returns to the center OFF position ... there'll be current draw through the pullups when not used. You can also connect it in such a way that no debouncing is required.

Here's a suggested circuit and code to get you started ...

If you use something like this in your code, you can read the input pins bounce free:

if (!digitalRead(dataA) && digitalRead(dataB)) {

// dataA is switched low
}
if (!digitalRead(dataB) && digitalRead(dataA)) {
 // dataB is switched low
}

Thanks dlloyd!

I've actually already completed it, and everything worked fine. I was worried about the minimum current when I bought it (as you stated as well), but it ended up working just fine. I have it directly connected to the 5V Power pin. As for the code, I just have an if/else if checking for a LOW on either of the two sides.