The KY-024 is a tilt sensor module designed to detect the angle of inclination. It operates using a ball switch mechanism, which closes the circuit when the module is tilted beyond a certain angle. This simple yet effective design makes the KY-024 ideal for applications requiring motion or tilt detection. Common use cases include robotics, gaming controllers, alarm systems, and other projects where orientation or movement needs to be monitored.
The KY-024 module has three pins for interfacing with external circuits. The table below describes each pin:
Pin | Name | Description |
---|---|---|
1 | VCC | Power supply pin. Connect to 3.3V or 5V. |
2 | GND | Ground pin. Connect to the ground of the power supply. |
3 | DO | Digital output pin. Outputs HIGH or LOW depending on the tilt state. |
4 | AO | Analog output pin. Provides a variable voltage based on the tilt angle. |
Below is an example of how to connect and use the KY-024 with an Arduino UNO to detect tilt events.
// KY-024 Tilt Sensor Example with Arduino UNO
// This code reads the digital output (DO) of the KY-024 and prints the tilt status.
const int tiltPin = 2; // KY-024 DO pin connected to digital pin 2
int tiltState = 0; // Variable to store the tilt state
void setup() {
pinMode(tiltPin, INPUT); // Set tiltPin as input
Serial.begin(9600); // Initialize serial communication at 9600 baud
}
void loop() {
tiltState = digitalRead(tiltPin); // Read the tilt state from the KY-024
if (tiltState == HIGH) {
// If the tilt sensor is activated
Serial.println("Tilt detected!");
} else {
// If the tilt sensor is not activated
Serial.println("No tilt detected.");
}
delay(500); // Wait for 500ms before reading again
}
No Output from the Module:
Erratic or Unstable Output:
Analog Output Not Responding:
Q: Can the KY-024 detect the exact angle of tilt?
A: The KY-024 provides an analog output (AO) that varies with the tilt angle, but it is not highly precise. For exact angle measurements, consider using a gyroscope or accelerometer module.
Q: How do I adjust the sensitivity of the tilt detection?
A: Use the onboard potentiometer to adjust the sensitivity. Rotate it clockwise or counterclockwise to increase or decrease the detection threshold.
Q: Can the KY-024 be used in battery-powered projects?
A: Yes, the KY-024 is suitable for battery-powered projects due to its low power consumption. Ensure the battery voltage matches the module's operating range.
Q: Is the KY-024 suitable for outdoor use?
A: The KY-024 is not weatherproof. If used outdoors, it should be enclosed in a protective casing to prevent damage from moisture or dust.