Cylewet 3Pin SPDT Micro Switch Long Hinge Lever for Arduino Review and Code

This post talks about using the Cylewet 3Pin SPDT Micro Switch Long Hinge Lever with an Arduino.

Cylewet 3Pin SPDT Micro Switch Long Hinge Lever

The Cylewet 3Pin SPDT Micro Switch Long Hinge Lever is a standard SPDT switch. The three pins are labelled C (common), NO (normally open), NC (normally closed).

SPDT stands for Single Pole Double Throw which means there is one common pin and two pins where one of them will be connected depending on the switch state.

By default the C and NC pins are connected. When the switch is pressed the C and NC will become disconnected and C and NO will be connected.

These switches are rated for 125 volts and 1 amp which means they can be used for higher voltage or amperage settings. However most of the time you will use these with low voltage circuits to read the signal from a micro-controller like the Arduino.

Since you are able to connect either NC or NO you can configure whether it will be on or off without pressing the switch. This gives a little more control over how you want to use it if you are using it with a circuit directly.

The size of the Switch is 12.6 × 6.5 × 5.7mm (Length * Height * Width)

The size of the lever arm is 13.5 x 4mm (Length * Width).

Wiring it up to an Arduino

To wire this up to an Arduino you need a 10k ohm resistor.

One of the pins on the button must be connected to the 5 volt line. I recommend using the common pin as in the diagram.

In a simple example one of the other pins should be connected to the GND and the 10k ohm resistor. This acts as a pull down resistor to ensure a clean LOW signal is received.

In addition this pin should be connected to one of the digital pins which will be used to read the state.

Programming the Arduino with the Cylewet 3Pin SPDT Micro Switch Long Hinge Lever

To check the state of the switch I can use a single digital pin configured on the Arduino.

#define SWITCH_PIN 8

void setup() {
  Serial.begin(115200);
  pinMode(SWITCH_PIN, INPUT);
}

void loop() {
  int btnState = digitalRead(SWITCH_PIN);
  Serial.println(btnState);
  delay(25);
}

Here I define the SWITCH_PIN constant as 8 which will be used as the digital pin to read the value. In the setup the serial is initialised and the switch pin is configured as an input.

In the main loop I read the button state using the SWITCH_PIN constant and save it to a variable. Then it is printed out and the Arduino is requested to wait for 25 millseconds after which it runs again.

Final Review

Overall this is a nice micro switch which needs little force to activate. Since it is SPDT you can easily configure it to either report HIGH when it is closed or open.

Would buy again!

Add a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.