hello everyone , i have a simple question i have a switch similar to this:
i want to make Arduino detect if its on or off (Both hardware and coding help needed) , then by coding i want to use that in another logic.
hello everyone , i have a simple question i have a switch similar to this:
i want to make Arduino detect if its on or off (Both hardware and coding help needed) , then by coding i want to use that in another logic.
Writing that you have a switch similar to an unclear photograph is not sufficient information for me.
Is your switch SPST? SPDT? Something else? Is there a center position? What type of Arduino do you have?
Let us suppose that you have pin 2 available on your Arduino. Then the general idea is:
A) Connect one side of the switch to ground.
B) Connect the other side of the switch to pin 2 on your Arduino.
C) Put the line
pinMode(2, INPUT_PULLUP);
in the setup() function.
D) Put the line
int switchValue = digitalRead(2);
in the loop() function. If switchValue has the value HIGH, then the switch is open (off). If switchValue has the value LOW, then the switch is closed (on).
Take a look at some of the examples available in the Arduino IDE. Learn from them.
Hi,
Ops switch.
This switch is a simple ON-OFF switch with a LED indicator in it.
Tom... ![]()
I see three terminals but there may be more. I cannot see which terminals are connected to the switch and which terminals are connected to the LED. I cannot tell if there is a resistor in series with the LED or what its value is. I do not know the polarity of the LED. I do not know whether the switch is in the closed or open state. I do not know whether the switch is SPST, DPST, SPDT, or something else. I do not know whether the switch has a center position. I do not know whether the switch has a spring return.
Other than that, it is a great photograph.