Welcome to RDK S100(P) Board repository
2.7 Example of GPIO read and write operations
Example of GPIO Read and Write Operations
Example of GPIO Read and Write Operations1. Environment Setup2. Running the Program3. Expected Results
The development board's /app/40pin_samples/ directory contains pre-installed functional test code for various 40-pin functions, including GPIO input/output testing, PWM, I2C, SPI, UART, etc. All test programs are written in Python. Detailed information can be found in other modules of this chapter.
Taking /app/40pin_samples/button_led.py as an example, this program configures pin 37 as an input and pin 36 as an output, and controls the output state of pin 36 based on the input state of pin 37.
1. Environment Setup
Connect pin 37 to 3.3V or GND using a jumper wire to control its high and low voltage levels.

2. Running the Program
Execute the button_led.py program to start the GPIO read and write program.
xxxxxxxxxxsunrise@ubuntu:~$ cd /app/40pin_samples/sunrise@ubuntu:/app/40pin_samples$ sudo python3 ./button_led.py3. Expected Results
By controlling the high and low voltage levels of pin 37, you can change the output voltage level of pin 36.
xxxxxxxxxxsunrise@ubuntu:/app/40pin_samples$ sudo python3 ./button_led.pyStarting demo now! Press CTRL+C to exitOutputting 0 to Pin 36Outputting 1 to Pin 36Outputting 0 to Pin 36