Top Ad unit 728 × 90


Raspberry Pi GPIO user manual (LED, Button Control Sample)

As Raspberry Pi developing for IOT today we will go to learn about GPIO of KIT BOARD.
Firstly look on the GPIO structure.
To control GPIO we have 2 method (Python)
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM) or GPIO.setmode(GPIO.BOARD)
So what is difference between GPIO.BCM and GPIO.BOARD 
GPIO.BCM --> Follow the Board Com pin
GPIO.BOARD --> Follow the IO Header assembly in Raspberry Pi KIT
Let start to wiring Led into Raspberry KIT as bellow

When we use LED we need get a Resistor series connect   to prevent over load for LED.
R = (U_Input – U_Led)/I_Led = (3,3V – 2V)/0.005 = 260ohm 
U_Input: GPIO Voltage Output
ULed and I Led always around 1.2V ~ 3V & 5mA

#Programe Code:
import RPi.GPIO as GPIO
from time import sleep
 
GPIO.setmode(GPIO.BOARD)
GPIO.setup(29, GPIO.OUT)
GPIO.setup(35, GPIO.IN, pull_up_down=GPIO.PUD_UP)
trywhile True:
    if GPIO.input(35) == False:
        GPIO.output(29, 1)
        sleep(0.3)
finally:
    GPIO.cleanup()  # clean up all port
Raspberry Pi GPIO user manual (LED, Button Control Sample) Reviewed by Unknown on December 08, 2016 Rating: 5

No comments:

All Rights Reserved by JackyLe © 2018 © 2017
Edit bởi: Jacky Le | Youtube Channel: JACKY LE

Send email form

Name

Email *

Message *

Powered by Blogger.