The Adafruit ANO Rotary Encoder to I2C Adapter is a compact module designed to simplify the integration of a rotary encoder into projects that utilize the I2C communication protocol. Rotary encoders are electromechanical devices that convert the angular position or motion of a shaft or axle to an analog or digital signal. This adapter allows for the rotary encoder's output to be easily read over the I2C bus, making it ideal for applications such as user interfaces, menu navigation, or input devices in embedded systems.
Pin | Description |
---|---|
GND | Ground |
VCC | Power supply (3.3V to 5V) |
SDA | I2C Data Line |
SCL | I2C Clock Line |
INT | Interrupt (optional use) |
VCC
pin to the power supply (3.3V or 5V, depending on your system).GND
pin to the ground of your system.SDA
and SCL
pins to the I2C data and clock lines, respectively.INT
pin to an interrupt-capable pin on your microcontroller if you wish to use the interrupt feature.SDA
and SCL
lines if they are not already provided by the microcontroller.#include <Wire.h>
// Define the I2C address for the rotary encoder (check your module documentation)
#define ENCODER_I2C_ADDRESS 0x40
void setup() {
Wire.begin(); // Join the I2C bus as a master
Serial.begin(9600); // Start serial communication for debugging
}
void loop() {
Wire.requestFrom(ENCODER_I2C_ADDRESS, 2); // Request 2 bytes from the encoder
if(Wire.available() == 2) {
int position = Wire.read(); // Read the first byte, which is the low byte
position |= Wire.read() << 8; // Read the second byte, which is the high byte
Serial.println(position); // Print the position value to the serial monitor
}
delay(100); // Small delay to prevent spamming the I2C bus
}
SDA
and SCL
lines are connected correctly and that pull-up resistors are in place.Wire
library functions such as Wire.beginTransmission()
and Wire.endTransmission()
to check for errors in communication.Q: Can I change the I2C address of the adapter? A: Yes, the I2C address is configurable. Refer to the Adafruit documentation for the specific procedure.
Q: What is the maximum rotation speed the adapter can handle? A: The maximum rotation speed will depend on the specific rotary encoder used and the I2C bus speed. Check the datasheet of your rotary encoder for more details.
Q: Is it possible to connect multiple encoders to the same I2C bus? A: Yes, as long as each encoder has a unique I2C address, you can connect multiple encoders to the same bus.
Remember to consult the Adafruit ANO Rotary Encoder to I2C Adapter datasheet for more detailed information and specifications.