Welcome to ROSMASTER A1 repository
13.GPIO readwrite operation
GPIO readwrite operation
In the development board /app/40pin_samples/ directory, a variety of 40PIN pin function test codes are preset, including gpio input/output test, PWM, I2C, SPI, UART and other tests. All test programs are written in Python language. For details, please refer to other modules in this chapter.
Taking /app/40pin_samples/button_led.py as an example, the program configures pin 37 as input, pin 36 as output, and controls the output state of pin 36 according to the input state of pin 37.
1. Environment Preparation
Use a Dupont wire to connect pin 37 to 3.3v or GND to control its high and low levels.

2. How it works
Execute the button_led.py program to start the GPIO reading and writing program
sunrise@ubuntu:~$ cd /app/40pin_samples/sunrise@ubuntu:/app/40pin_samples$ sudo python3 ./button_led.py3. Expected Results
By controlling the high and low levels of pin 37, the output level value of pin 36 can be changed.
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