1 176 octets ajoutés
, 12 septembre 2013 à 11:23
{{Pi-WiringPi-NAV}}
== Intro ==
Blink is the “Hello World” of the GPIO interfacing world. It’s the simplest program and circuit that lets you see something happening.
== Brancher ==
To see the output of this, you would need to connect a single LED to the GPIO connector of the Raspberry Pi as follows:
[[Fichier:Pi-WiringPi-Exemple-LED-01.jpg]]
and if all goes well, you should see the LED flashing once a second.
The LED is any generic LED you may have – typically 5mm diameter and the resistor is 330Ω.
== Code et compilation ==
If you have the following saved in a file called blink.c:
<nowiki>#include <wiringPi.h>
main ()
{
wiringPiSetup () ;
pinMode (0, OUTPUT) ;
for (;;)
{
digitalWrite (0, HIGH) ; delay (500) ;
digitalWrite (0, LOW) ; delay (500) ;
}
}</nowiki>
then to compile and run, you would enter:
<nowiki>gcc -Wall -o blink blink.c -lwiringPi
sudo ./blink</nowiki>
== Autres exemples ==
You can find blink.c and others – blink8.c and blink12.c in the examples directory of the wiringPi distribution. To use the makefile to compile them:
<nowiki>make blink
make blink8
make blink12</nowiki>
{{Pi-WiringPi-TRAILER}}