The simplest of a Raspberry Pi Gpio operation Getting started, here is a record of the following
First on the connection diagram:
Horizontal slots. Figure Akzent The Big
Using the Gpio gnd and #18 pins, this is not, the red wire is 18 pins, the dark line is the GND pin, the following Python code:
1 #Coding:utf-82 ImportGpi.gpio as GPIO3 Import Time4 5 Gpio.setmode (GPIO). BCM)6 gpio.setwarnings (False)7Gpio.setup (18, GPIO. Out)8 9 #gpio.output (True)Ten #time.sleep (1) #睡眠1s One #gpio.output (False) A - whileTrue: -Gpio.output (18, True) theTime.sleep (1)#sleep 1s -Gpio.output (18, False) -Time.sleep (1)#sleep 1s
Just save a file name, execute the Python file under Linux terminal, if not root user, sudo is required.
This code actually executes when there is a problem, because it is an infinite loop, so I want to end only CTRL + C, but this end after the LED is still flashing, according to the book copy, the book did not mention this problem, so I added 9-11 lines of code, CTRL + C after the 9-11 lines of code uncomment, 13-17 lines with a comment, then execute it again
Play Raspberry Pi Development code is not difficult, it is difficult to know so many gpio pins to plug which, resistance to choose how to beat the method of wiring, slowly groping it, work to learn python, work to play Raspberry Pi
Raspberry Pi--Operation LED