

The Adafruit KB2040 (Manufacturer Part ID: 5302) is a compact microcontroller board based on the RP2040 chip, designed specifically for keyboard and other input device projects. It features a USB-C interface, multiple GPIO pins, and support for various peripherals. The KB2040 is programmable using CircuitPython, MicroPython, or C/C++, making it versatile for both beginners and advanced users.








The Adafruit KB2040 is packed with features that make it ideal for compact and efficient designs. Below are its key technical details:
The KB2040 features a total of 20 GPIO pins, which are broken out to the sides of the board. Below is the pinout description:
| Pin | Name | Function |
|---|---|---|
| 1 | GND | Ground |
| 2 | 3V3 | 3.3V power output |
| 3 | A0 (GP26) | Analog input 0 / GPIO 26 |
| 4 | A1 (GP27) | Analog input 1 / GPIO 27 |
| 5 | A2 (GP28) | Analog input 2 / GPIO 28 |
| 6 | A3 (GP29) | Analog input 3 / GPIO 29 |
| 7 | GP0 | General-purpose I/O pin 0 |
| 8 | GP1 | General-purpose I/O pin 1 |
| 9 | GP2 | General-purpose I/O pin 2 |
| 10 | GP3 | General-purpose I/O pin 3 |
| 11 | GP4 | General-purpose I/O pin 4 |
| 12 | GP5 | General-purpose I/O pin 5 |
| 13 | GP6 | General-purpose I/O pin 6 |
| 14 | GP7 | General-purpose I/O pin 7 |
| 15 | GP8 | General-purpose I/O pin 8 |
| 16 | GP9 | General-purpose I/O pin 9 |
| 17 | GP10 | General-purpose I/O pin 10 |
| 18 | GP11 | General-purpose I/O pin 11 |
| 19 | SDA (GP20) | I2C data line / GPIO 20 |
| 20 | SCL (GP21) | I2C clock line / GPIO 21 |
The Adafruit KB2040 is designed to be easy to use for a variety of projects. Below are the steps and best practices for using the board.
Powering the Board:
Programming the Board:
Connecting Peripherals:
Uploading Code:
Below is an example of using the KB2040 to control an LED:
// Example: Blink an LED connected to GPIO 5 (GP5)
// Define the GPIO pin for the LED
#define LED_PIN 5
void setup() {
pinMode(LED_PIN, OUTPUT); // Set GPIO 5 as an output
}
void loop() {
digitalWrite(LED_PIN, HIGH); // Turn the LED on
delay(1000); // Wait for 1 second
digitalWrite(LED_PIN, LOW); // Turn the LED off
delay(1000); // Wait for 1 second
}
Board Not Recognized by Computer:
Code Not Running:
GPIO Pins Not Responding:
Overheating or Power Issues:
Can I use the KB2040 for non-keyboard projects?
Yes, the KB2040 is a general-purpose microcontroller and can be used for a wide range of applications.
What programming languages are supported?
The KB2040 supports CircuitPython, MicroPython, and C/C++ (via the Arduino IDE or other development environments).
How do I reset the board?
Press the RESET button on the board to restart it. To enter bootloader mode, hold the BOOT button while pressing RESET.
What is the maximum current output of the GPIO pins?
Each GPIO pin can source or sink up to 12 mA. For higher currents, use an external transistor or driver circuit.
This concludes the documentation for the Adafruit KB2040. For additional resources, visit the Adafruit KB2040 product page.