当前位置:网站首页>1. Summary of GPIO control of nanopi M1 (Quanzhi H3) based on wiringpi

1. Summary of GPIO control of nanopi M1 (Quanzhi H3) based on wiringpi

2022-04-23 22:03:00 July meteor

development environment :linux-3.4( Development board )

step :

1. install WiringPi library :

git clone https://github.com/friendlyarm/WiringNP
cd WiringNP/
chmod 755 build
./build

      Check whether the installation is successful :

gpio readall

2. To write LED The test program

        nanopi m1 Of pin7(GPIOG11) Pin connection LED The positive pole of ,LED The negative pole of the is grounded GND, The procedure is as follows :

vi led_control.c
#include <wiringPi.h>
int main(void)
{
  wiringPiSetup() ;
  pinMode (7, OUTPUT) ;
  for(;;)
  {
    digitalWrite(7, HIGH) ;
    delay (500) ;
    digitalWrite(7,  LOW) ;
    delay (500) ;
  }
}

3. To write Makefile

led_control:led_control.c
    gcc -Wall -o led_control led_control.c -lwiringPi -lpthread

.PHONY:
clean:
    rm -rf led_control

4. Execution procedure

./led_control

Running results :

    LED Light flashing

版权声明
本文为[July meteor]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204200609125685.html