创建日期:2019-03-18
1. 创建一个叫做blink的新Qt工程

Creat New Project 

Name it blink
2. 更改工程配置
- 在blink.pro中新增一行:
LIBS += -lwiringPi 
#-------------------------------------------------
#
# Project created by QtCreator 2019-03-18T13:54:32
#
#-------------------------------------------------
QT       += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = bink
TEMPLATE = app
# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
SOURCES += main.cpp\
        mainwindow.cpp
HEADERS  += mainwindow.h
FORMS    += mainwindow.ui
LIBS += -lwiringPi

blink.pro
3. 更改Sources/mainwindow.cpp文件
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <wiringPi.h>
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    wiringPiSetup();
    pinMode(7, OUTPUT);
    while (1) {
        digitalWrite(7, HIGH);
        delay(500);
        digitalWrite(7, LOW);
        delay(500);
    }
}
MainWindow::~MainWindow()
{
    delete ui;
}

mainwindow.cpp
4. 接线测试
- 
将树莓派的7、6针分别通过电阻接到发光二极管上
引脚定义 

7、6针
- 
运行Qt程序,即可实现闪烁
blink成功 

