Raspberry Pi--Operation LED

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.