40PIN GPIOs and BLINK-LED
The article details the 40P GPIO interface on Edge101, explaining its configurations, capabilities, and multiplexing functions, and provides practical guidance on controlling an onboard LED using sample code.
GPIO
The 40-pin expansion interface on the Edge101 mainboard provides 11 GPIOs and is equipped with Gravity 3-pin and 4-pin I2C interfaces, allowing direct connection to DFRobot's Gravity devices.
The GPIOs support internal pull-up, pull-down, or high-impedance configurations. When used as inputs, the values can be read through registers, and they support edge or level-triggered CPU interrupts.
All IO pins are bidirectional, non-inverting, and tri-state designed, supporting input, output, and tri-state control functions. Additionally, they can be multiplexed for other functions such as SDIO, UART, and SPI.
40PIN Expansion Interface Diagram

40PIN Expansion Interface Diagram
| Pin Name | GPIO Function | ADC Function | Communication Function | Multiplexing Function |
|---|---|---|---|---|
| P5 | GPIO5, supports input/output | SPICS0 | Gravity SPICS0 | |
| P12 | GPIO12, supports input/output | ADC2_CH5 | SPI-SDO | Gravity SPI-SDO |
| P14 | GPIO14, supports input/output | ADC2_CH6 | SPI-CLK | Gravity SPI-CLK |
| P15 | GPIO15, supports input/output | ADC2_CH3 | Onboard LED | |
| P18 | GPIO18, supports input/output | I2C-SDA | Gravity I2C-SDA | |
| P23 | GPIO23, supports input/output | I2C-SCL | Gravity I2C-SCL | |
| P33 | GPIO33, supports input/output | U1TXD | PCIe Slot U1TXD | |
| P34 | GPIO34, input only | U1RXD | PCIe Slot U1RXD | |
| P37 | GPIO37, input only | ADC1_CH1 | ||
| P38 | GPIO38, input only | ADC1_CH2 | Onboard Button | |
| P39 | GPIO39, input only | ADC1_CH3 | SPI-SDI | Gravity SPI-SDI |
Note:
- GPIO34 to GPIO38 can only be used as inputs and do not support PULLUP or PULLDOWN modes. When using analog input, you must use the GPIOs connected to the ADC. However, if you use wireless communication such as Wi-Fi, ADC 2 will be unavailable.
- The following GPIOs have built-in pull-up or pull-down resistors:
- GPIO0: Internal pull-up
- GPIO5: Internal pull-up
- GPIO12: Internal pull-down (Default setting ensures FLASH operates at 3.3V. Forcing an external pull-up may cause the board to malfunction.)
Example: Controlling the LED
Set P38 (connected to the onboard button) as an input and P15 (connected to the onboard LED) as an output. When the button is pressed, the LED lights up.
Hardware Preparation:
- ESP32 IoT Programmable Controller (SKU: DFR0886)×1
Sample Code:
const int buttonPin = 38; // GPIO38 for the onboard button
const int ledPin = 15; // GPIO15 for the onboard LED
// Variable will change
int buttonState = 0; // Use a variable to store the button state
void setup() {
// If the external circuit does not have a pull-up or pull-down resistor,
// enable the internal pull-up or pull-down resistor when using GPIO as an input
// to accurately detect the signal level.
// Initialize button pin as input without enabling pull-up or pull-down
pinMode(buttonPin, INPUT);
// Initialize button pin as input with pull-up enabled
// pinMode(buttonPin, INPUT_PULLUP);
// Initialize button pin as input with pull-down enabled
// pinMode(buttonPin, INPUT_PULLDOWN);
pinMode(ledPin, OUTPUT); // Initialize LED pin as output
pinMode(buttonPin, INPUT); // Initialize button pin as input
}
void loop() {
// Read the button state
buttonState = digitalRead(buttonPin);
// If the button input is LOW, the button is pressed, and the onboard green user LED will turn on
if (buttonState == LOW) {
// Turn on the LED
digitalWrite(ledPin, LOW);
} else {
// Turn off the LED
digitalWrite(ledPin, HIGH);
}
}
Result:
When the button KEY (P38) is pressed, the LED (P15) lights up. When the button is released, the LED turns off.
Was this article helpful?
