Raspberry Pi B的UART极简例程

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/CharmingSun/article/details/50880206

一、安装WiringPi2-Python

执行以下命令:

sudo apt-get update
sudo apt-get install python-dev python-pip
sudo pip install wiringpi2

二、编辑Python代码

创建如下Serial.py文件,并增加可执行权限:

#!/usr/bin/env python
import wiringpi
wiringpi.wiringPiSetup()
serial = wiringpi.serialOpen('/dev/ttyAMA0',9600)
wiringpi.serialPuts(serial,'Hello World!')

三、连接硬件并执行程序

按照管脚图接好杜邦线,然后执行Serial.py程序:
Raspberry Pinout

本文参考链接:
UART at Raspberry Pi GPIO Pinout
How to install WiringPi2 for Python on the Raspberry Pi

猜你喜欢

转载自blog.csdn.net/CharmingSun/article/details/50880206