
The circuit consists of two rotary encoders (Kalamoyi P3022-V1-CW360) connected to two STG adapters. Each encoder's VCC, OUT, and GND pins are connected to the corresponding STG adapter, facilitating signal transmission and power supply management.

The KY-040 is a rotary encoder that detects rotational position and direction. Unlike a potentiometer, which provides an absolute position, the KY-040 outputs quadrature pulses that indicate relative movement. This makes it ideal for applications requiring precise control or incremental adjustments. Additionally, the KY-040 includes a built-in push button, expanding its functionality for user interface controls.

The circuit consists of two rotary encoders (Kalamoyi P3022-V1-CW360) connected to two STG adapters. Each encoder's VCC, OUT, and GND pins are connected to the corresponding STG adapter, facilitating signal transmission and power supply management.

This circuit is designed for a comprehensive security and access control system with motion detection, access via RFID, and a break-beam sensor. It includes a solenoid lock controlled by a relay, visual and audible alerts, and a robust power management system with solar and battery backup to ensure uninterrupted operation.

This circuit appears to be a configurable encoder system with an RF transmission capability. The encoder's address pins (A0-A7) are connected to a DIP switch for setting the address, and its data output (DO) is connected to an RF transmitter, allowing the encoded signal to be wirelessly transmitted. The circuit is powered by a 9V battery, regulated to 5V by a 7805 voltage regulator, and includes a diode for polarity protection. Tactile switches are connected to the encoder's data inputs (D1-D3), and an LED with a current-limiting resistor indicates power or activity.

This circuit is a MIDI controller that uses an nRF52840 ProMicro microcontroller, multiple AS5600 magnetic encoders, an Adafruit TCA9548A I2C multiplexer, an OLED display, and several pushbuttons. The microcontroller reads the encoder positions and button states, displays information on the OLED screen, and sends MIDI signals based on user interactions.
The KY-040 rotary encoder has the following key specifications:
| Parameter | Value |
|---|---|
| Operating Voltage | 3.3V to 5V |
| Output Type | Digital (Quadrature Pulses) |
| Number of Pulses per Revolution | 20 |
| Push Button Type | Momentary (Normally Open) |
| Operating Temperature | -40°C to +85°C |
| Dimensions | 19mm x 15mm x 29mm |
The KY-040 has 5 pins, as described in the table below:
| Pin | Name | Description |
|---|---|---|
| 1 | GND | Ground connection |
| 2 | + | Power supply (3.3V to 5V) |
| 3 | SW | Push button output (active LOW) |
| 4 | DT | Data signal (used for detecting rotation direction, works with CLK) |
| 5 | CLK | Clock signal (used for detecting rotation steps, works with DT) |
+ pin to a 3.3V or 5V power source and the GND pin to ground.CLK and DT pins to digital input pins on your microcontroller.SW pin to a digital input pin on your microcontroller.CLK and DT signals to detect rotation.SW signal to detect button presses.SW, CLK, and DT pins if your microcontroller does not have internal pull-ups.Below is an example of how to use the KY-040 with an Arduino UNO to detect rotation and button presses:
// Define pins for the KY-040 encoder
#define CLK 2 // Clock pin connected to digital pin 2
#define DT 3 // Data pin connected to digital pin 3
#define SW 4 // Switch pin connected to digital pin 4
int lastCLKState; // To store the previous state of the CLK pin
int currentCLKState; // To store the current state of the CLK pin
int counter = 0; // Counter to track rotation steps
void setup() {
pinMode(CLK, INPUT); // Set CLK pin as input
pinMode(DT, INPUT); // Set DT pin as input
pinMode(SW, INPUT_PULLUP); // Set SW pin as input with pull-up resistor
Serial.begin(9600); // Initialize serial communication
lastCLKState = digitalRead(CLK); // Read the initial state of the CLK pin
}
void loop() {
// Read the current state of the CLK pin
currentCLKState = digitalRead(CLK);
// Check if the CLK state has changed
if (currentCLKState != lastCLKState) {
// Determine rotation direction based on the DT pin state
if (digitalRead(DT) != currentCLKState) {
counter++; // Clockwise rotation
} else {
counter--; // Counterclockwise rotation
}
// Print the counter value to the serial monitor
Serial.print("Counter: ");
Serial.println(counter);
}
// Update the last CLK state
lastCLKState = currentCLKState;
// Check if the push button is pressed
if (digitalRead(SW) == LOW) {
Serial.println("Button Pressed!");
delay(200); // Debounce delay
}
}
CLK and DT pins are used to detect rotation direction and steps.SW pin is used to detect button presses.No Response from the Encoder:
+ and GND pins.CLK and DT pins are connected to the correct digital input pins on the microcontroller.Incorrect Rotation Direction:
CLK and DT pins to correct the direction.Button Not Detected:
SW pin is connected properly.Noisy or Erratic Output:
CLK and GND pins and between the DT and GND pins.Q: Can the KY-040 be used with 3.3V microcontrollers like the ESP32?
A: Yes, the KY-040 operates at 3.3V to 5V, making it compatible with 3.3V microcontrollers.
Q: How many steps does the KY-040 encoder have per revolution?
A: The KY-040 has 20 steps per full revolution.
Q: Do I need external pull-up resistors for the KY-040?
A: If your microcontroller does not have internal pull-ups, you will need to add external pull-up resistors for the SW, CLK, and DT pins.
Q: Can I use the KY-040 for absolute position sensing?
A: No, the KY-040 is a relative encoder and does not provide absolute position information.