Difference between revisions of "WiringNP in QT"
Jump to navigation
Jump to search
(Created page with "== Installing WiringNP == The WiringNP in the /root folder, at least for NanoPI K1 Plus, is not good. It shows the NanoPI Neo/Neo2 GPIOs. Reinstall it from sources: git cl...") |
|||
(One intermediate revision by the same user not shown) | |||
Line 13: | Line 13: | ||
gpio readall | gpio readall | ||
+ | |||
+ | == Basic C test == | ||
+ | |||
+ | #include <wiringPi.h> | ||
+ | int main(void) | ||
+ | { | ||
+ | wiringPiSetup(); | ||
+ | pinMode(21, OUTPUT); | ||
+ | for(;;) | ||
+ | { | ||
+ | digitalWrite(21, HIGH); | ||
+ | delayMicroseconds(500); | ||
+ | digitalWrite(21, LOW); | ||
+ | delayMicroseconds(3500); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | Compile with: | ||
+ | |||
+ | gcc -Wall -o test test.c -lwiringPi -lpthread | ||
== Use in QT == | == Use in QT == | ||
Line 29: | Line 49: | ||
wiringPiSetup(); | wiringPiSetup(); | ||
+ | |||
+ | before doing any other operation. | ||
+ | |||
+ | If you want to use it for PWM output, in QT it's really unstable, at least for frequencies above 50Hz. |
Latest revision as of 19:43, 20 April 2020
Installing WiringNP[edit]
The WiringNP in the /root folder, at least for NanoPI K1 Plus, is not good. It shows the NanoPI Neo/Neo2 GPIOs.
Reinstall it from sources:
git clone https://github.com/friendlyarm/WiringNP cd WiringNP/ chmod 755 build ./build
then, check it via gpio command
gpio readall
Basic C test[edit]
#include <wiringPi.h> int main(void) { wiringPiSetup(); pinMode(21, OUTPUT); for(;;) { digitalWrite(21, HIGH); delayMicroseconds(500); digitalWrite(21, LOW); delayMicroseconds(3500); } }
Compile with:
gcc -Wall -o test test.c -lwiringPi -lpthread
Use in QT[edit]
Add the following line to <project>.pro:
LIBS += /usr/local/lib/libwiringPi.so
It will include the libpthread.so library automatically.
In the files, don't forget to add
#include <wiringPi.h>
and
wiringPiSetup();
before doing any other operation.
If you want to use it for PWM output, in QT it's really unstable, at least for frequencies above 50Hz.