Différences entre versions de « Pi-WiringPi-Exemple-LED »
(Page créée avec « {{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.... ») |
|||
Ligne 8 : | Ligne 8 : | ||
To see the output of this, you would need to connect a single LED to the GPIO connector of the Raspberry Pi as follows: | 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]] | + | [[Fichier:Pi-WiringPi-Exemple-LED-01.jpg|480px]]<br /><small>Source: [http://wirinPi.com wiringPi.com]</small> |
and if all goes well, you should see the LED flashing once a second. | and if all goes well, you should see the LED flashing once a second. |
Version actuelle datée du 12 septembre 2013 à 11:26
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:
Source: wiringPi.com
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:
#include <wiringPi.h> main () { wiringPiSetup () ; pinMode (0, OUTPUT) ; for (;;) { digitalWrite (0, HIGH) ; delay (500) ; digitalWrite (0, LOW) ; delay (500) ; } }
then to compile and run, you would enter:
gcc -Wall -o blink blink.c -lwiringPi sudo ./blink
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:
make blink make blink8 make blink12
Source: WiringPi.com. WiringPi est une libraire sous licence GPL écrite par Gordon Henderson. Crédit: wiringpi.com
Traduit de l'anglais par Meurisse D. pour MCHobby.be
Traduit avec l'accord de Gordon Henderson, créateur de wiringPi - Translated with authorization of Gordon Henderson, creator of wiringPi
Toute référence, mention ou extrait de cette traduction doit être explicitement accompagné du texte suivant : « Traduction par MCHobby (www.MCHobby.be) - Vente de kit et composants » avec un lien vers la source (donc cette page) et ce quelque soit le média utilisé.
L'utilisation commercial de la traduction (texte) et/ou réalisation, même partielle, pourrait être soumis à redevance. Dans tous les cas de figures, vous devez également obtenir l'accord du(des) détenteur initial des droits. Celui de MC Hobby s'arrêtant au travail de traduction proprement dit.