Raspberry Pi GPIO Blink

Blink is the “Hello World” of the GPIO interfacing world. It’s the simplest program and circuit that lets you see something happening.

$ git clone git://git.drogon.net/wiringPi
$ cd wiringPi
$ ./build
$ vim blink.c
#include 
int main (void)
{
  wiringPiSetup () ;
  pinMode (0, OUTPUT) ;
  for (;;)
  {
    digitalWrite (0, HIGH) ; delay (500) ;
    digitalWrite (0,  LOW) ; delay (500) ;
  }
  return 0 ;
}
</pre>
$ gcc -Wall -o blink blink.c -lwiringPi
$ sudo ./blink

接线方式,这里我使用了GPIO转接板

@pinMode (0, OUTPUT)@ 表示P0这个接口,正极接P0,负极接一个330欧姆的电阻。

参考:http://wiringpi.com/examples/blink/

https://projects.drogon.net/raspberry-pi/wiringpi/pins/

http://hugozhu.myalert.info/2013/03/22/19-raspberry-pi-gpio-port-naming.html

</section>