Welcome to Raspberry Pi 4B repository
3.Pin output level
!Note:
The maximum continuous input and output voltage of the Raspberry Pi's GPIO pin is 3.3V. Do not connect it directly with other electronic components, otherwise it will damage the Raspberry Pi.
Step 1:Create and open gpio.py file
nano gpio.py
Step 2: Writing code
import wiringpi
GPIO_Pin = 0
OUTPUT = 1
HIGH = 1
LOW = 0
wiringpi.wiringPiSetup()
wiringpi.pinMode(GPIO_Pin,OUTPUT)
while 1:
print ('Set GPIO_Pin => H')
wiringpi.digitalWrite(GPIO_Pin,HIGH)
wiringpi.delay(500)
print ('Set GPIO_Pin => L')
wiringpi.digitalWrite(GPIO_Pin,LOW)
wiringpi.delay(500)
After writing, press Ctrl + X to exit this file.
The system will prompt you whether you need to save, press Y to save and exit.
Step 3: Run this code
python3 gpio.py
According to the printed information, we can see that GPIO0_Pin will alternately output high and low levels.