2016년 9월 21일 수요일

Using GPIO in Raspberry pi

GPIO(General Purpose Input Output)



Some sensor is necessary a breadboard

The basic use of sensor is connecting 5V and GND to a sensor(or a breadboard),
then select data line for data sending.
(#4, #17, #18... etc)


You can use GPIO in raspberry using RPi.GPIO Module in python.

python code


# -*- coding: utf8 -*-

from RPi.GPIO as GPIO

GPIO.setmode(GPIO.BCM)
GPIO.setup(4, GPIO.IN, pull_up_down=GPIO.PUB_UP)

print GPIO.input(4)


The example displays data reading from #4.
You can process various data from sensor.
(Fire sensor, Temperature sensor...)

댓글 없음:

댓글 쓰기