The LilyPad Reed Switch is a magnetic switch designed to be easily integrated into e-textiles and wearable projects. It is part of the LilyPad Arduino ecosystem, a set of sewable electronic components that can be used to build interactive garments and accessories. The reed switch activates when a magnetic field is applied, making it ideal for creating switches in clothing without the need for hard mechanical parts.
Pin Number | Description | Notes |
---|---|---|
1 | S (Signal) | Connects to digital I/O pin |
2 | +(Positive) | Connects to VCC (3.3V - 5V) |
3 | -(Negative) | Connects to ground (GND) |
+
pin to the VCC of your LilyPad Arduino or compatible microcontroller.-
pin to the ground (GND) of your microcontroller.S
pin to a digital I/O pin on the microcontroller.// Define the pin connected to the LilyPad Reed Switch
const int reedSwitchPin = 2;
void setup() {
// Initialize the reed switch pin as an input
pinMode(reedSwitchPin, INPUT);
// Begin serial communication at 9600 baud rate
Serial.begin(9600);
}
void loop() {
// Read the state of the reed switch
int switchState = digitalRead(reedSwitchPin);
// If the switch is closed (magnet is near), print a message
if (switchState == HIGH) {
Serial.println("The reed switch is closed.");
} else {
Serial.println("The reed switch is open.");
}
// Small delay to prevent overwhelming the serial output
delay(200);
}
Q: Can the LilyPad Reed Switch be washed?
Q: How close does the magnet need to be to activate the switch?
Q: Is it possible to use the reed switch with a battery?