I bought an “MC-38 Door And Window Sensor” from AliExpress. And I wanted to make a Morse code machine. The first step of that was the sensor.
Schematic

Code
// main.ino
const int sensor = 5;
void setup() {
  pinMode(sensor, INPUT_PULLUP);
  Serial.begin(9600);
}
void loop() {
  /**
   * On the door sensor:
   *   0 - the circuit is complete.
   *   1 - the circuit is broken.
   */
  Serial.println(digitalRead(sensor));
  delay(200);
}
Sample output

Links may be affiliate links, thanks for your support.
