How To: GPIO Pins
You can use many GPIO pins (General Purpose Input/Output pins) to connect the Core Module with the outside world.
The pins are described in the Header Pinout. The pins in SDK have the names
TWR_GPIO_P17. There are also two special pins dedicated to
- GPIO SDK Module
- GitHub Repository Example
This example will turn on the LED on the Core Module. The usual and more comfortable way to control LED is to use
twr_led code, but we use
twr_gpio for now to explain the GPIO basics.
GPIO as Output Code Example
This example will read the button state and based on that the LED will be set to the ON/OFF state.
GPIO Input and Output Code Example
// The Core Module has hardware pull-down so next call is commented out
// twr_gpio_set_pull(TWR_GPIO_BUTTON, TWR_GPIO_PULL_DOWN);
uint8_t button_state = twr_gpio_get_input(TWR_GPIO_BUTTON);
// Repeat this task again after 10 ms