Raspberry Pi Gpio Input output-control LED

Source: Internet
Author: User

  

The GPIO pin has two modes board and BCM.

1.GPIO output Control LED

  

Code:

    

(1) Using board mode, GPIO.setmode(GPIO.BOARD) . Pin 35th is GPIO19 under BCM.

(2) Set pin 35 to output mode,GPIO.setup(35,GPIO.OUT)

(3) on the GPIO35 pin output high level, can also be Gpio.high

2.GPIO interface for input signal

  

Circuit diagram

  

When the switch is off, the GPIO23 is the high point level to obtain the input signal is ture. When the switch is pressed, the GPIO23 is grounded, and the obtained signal is false.

Code:

  

(1) for the use of 35 as the output pin, 36 as the input pin.

(2)"Gpio.setup (Channel,gpio. In,pull_up_down=gpio. PUD_UP) "Set the input port to pull-up mode to

Raspberry Pi Gpio Input output-control 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.