The set contains three of these sensors
Between the pin S and the pin GND - the sensor is switched. A 10kOhm resistor is switched as a pull-up resistor between S and the middle pin. The sensor itself consists of an elongated plastic box in which there is a spring which is equipped with a contact at the end. The contact has a small distance from the underlying contact surface. The switch is open by a push from above or below swings the spring up and down so that the contact at the end of the spring touches the contact surface. The switch is closed. Since the contact is closed several times in case of a shock, the sensor on the Arduino must be connected to an interruptable input in order to register the event safely. The sensor has a medium sensitivity.
This sensor contains two metal balls that close the two contacts in case of shocks. More detailed information on how the switch is set up could not be found. The type designation is HDX 2100. The ball switch lies between the shots S and -. The S connector is also connected to the middle pin via a 10kOhm resistor. If you put +5V to the middle pin, this resistor serves all pullup resistance. Since the contact is closed for a short time in case of vibrations, the use of an interruptable input is also recommended here. The sensor responds to stronger vibrations and position changes.
The tilt switch also uses zei balls to make contact. If the tube is tilted upwards with the balls, the balls fall down and close the contact. This happens already at small angles of about 10 degrees. The sensor can be operated as a digital input, but again the use of an interrupt is useful, because at small angles the contact is not very stable. The sensor is quite sensitive and is particularly suitable for detecting inclinations. However, it is also suitable for detecting vibrations, but this requires the use of an interrupt.
The circuit is very simple and identical for all three modules. - is connected to GND and the middle pin to +5V. We connect the sensor output S to the interruptable input D2. As an indication we use the internal led to pin D13.
const byte display = 13;
const byte sensor = 2;
const byte dauer = 1000; Timing
byte led = LOW; current state of the display Led
Pre-assign preparation sensor as input and interrupt
The interrupt service routine is called service and the interrupt
should extend with the falling flank
Interrupt Service Routine
Called when the sensor input goes to 0
led = HIGH; led is set to HIGH
digitalWrite (display,led);current state is output
if state is HIGH, we leave the led switched on longer,
so that we can perceive the event
if (led == HIGH)
then we reset the value