The Adafruit NeoTrellis 4x4 is a programmable keypad with a built-in RGB LED for each button. This interactive and visually appealing component is perfect for creating custom user interfaces, musical instruments, and gaming controls. Its versatility allows it to be used in a wide range of projects, from simple educational tools to complex interactive installations.
Pin | Description |
---|---|
VDD | Power supply (2.5V to 5.5V) |
GND | Ground |
SCL | I2C clock line |
SDA | I2C data line |
INT | Interrupt output (active low) |
RST | Reset input (active low) |
#include <Wire.h>
#include "Adafruit_NeoTrellis.h"
Adafruit_NeoTrellis trellis;
void setup() {
Wire.begin();
trellis.begin();
// Activate all keys and LEDs for the NeoTrellis
for (int i = 0; i < 16; i++) {
trellis.activateKey(i, SEESAW_KEYPAD_EDGE_RISING, true);
trellis.setPixelColor(i, 0x000000); // Start with all LEDs off
}
trellis.show();
}
void loop() {
// If available, read key event
if (trellis.available()) {
keypadEvent e = trellis.read();
if (e.bit.EDGE == SEESAW_KEYPAD_EDGE_RISING) {
trellis.setPixelColor(e.bit.NUM, 0xFFFFFF); // Turn on LED when button is pressed
trellis.show();
}
}
}
Q: Can I connect multiple NeoTrellis boards together? A: Yes, you can daisy-chain multiple boards using the I2C bus. Make sure to configure unique I2C addresses for each board.
Q: How do I change the color of an LED?
A: Use the setPixelColor
function with the button number and desired RGB color value.
Q: What is the maximum number of NeoTrellis boards I can chain together? A: The maximum number is limited by the I2C address space and the power supply capability. Typically, you can chain several boards without issues.
Q: Can I use the NeoTrellis with platforms other than Arduino? A: Yes, the NeoTrellis can be used with any microcontroller that supports I2C communication. Adjust the code accordingly for your platform.