Modifications

Sauter à la navigation Sauter à la recherche
Ligne 12 : Ligne 12 :  
== Tester le module principal ==
 
== Tester le module principal ==
    +
=== Led et bouton ===
 
The button is connected to pin 0 and the LED to pin 1 du GPIO. The button is wired so that the input reads 1 when you push the button.
 
The button is connected to pin 0 and the LED to pin 1 du GPIO. The button is wired so that the input reads 1 when you push the button.
   Ligne 30 : Ligne 31 :     
should return 1 when you push the button, otherwise 0.
 
should return 1 when you push the button, otherwise 0.
 +
 +
=== Ajouter une LED ===
    
At the bottom of the main board is the external GPIO connector as well as some power and ground pins. The GPIO outputs have series resistors, so can be connected directly to LEDs – I connected an LED between 0v and pin7.
 
At the bottom of the main board is the external GPIO connector as well as some power and ground pins. The GPIO outputs have series resistors, so can be connected directly to LEDs – I connected an LED between 0v and pin7.
   −
[[Fichier:Pi-WiringPi-Exemple-Quick2Wire-Install.jpg|640px]]<br /><small>Source: [http://wirinPi.com wiringPi.com]</small>
+
[[Fichier:Pi-WiringPi-Exemple-Quick2Wire-Install.jpg|640px]]<br /><small>Source: [http://wirinPi.com wiringPi.com]<br />Testing the board. LED is connected from pin 7 to GND (0v) Long leg to pin 7… Also note the jumpers next to the on-board LED and button near the middle-right of the board.</small>
    
Exécutez ensuite le code suivant:
 
Exécutez ensuite le code suivant:
Ligne 42 : Ligne 45 :  
and used the button to toggle the LED on pin 7 in the same way as above.
 
and used the button to toggle the LED on pin 7 in the same way as above.
   −
  <nowiki></nowiki>
+
So the main board on its own is already quite versatile, and using BASH and the command line, we can perform some simple tests on it.
 +
 
 +
== Le programme en C ==
 +
The standard “blink” program in C is:
 +
 
 +
  <nowiki>#include <stdio.h>
 +
#include <wiringPi.h>
 +
 
 +
#define LED    1
 +
 
 +
int main (void)
 +
{
 +
  printf ("Raspberry Pi Quick2Wire blink\n") ;
 +
 
 +
  wiringPiSetup () ;
 +
  pinMode (LED, OUTPUT) ;
 +
 
 +
  for (;;)
 +
  {
 +
    digitalWrite (LED, HIGH) ;  // On
 +
    delay (500) ;              // mS
 +
    digitalWrite (LED, LOW) ;  // Off
 +
    delay (500) ;
 +
  }
 +
  return 0 ;
 +
}</nowiki>
 +
 
 +
Compile this with:
 +
 
 +
<nowiki>gcc -o blink blink.c -lwiringPi</nowiki>
 +
 
 +
and run:
 +
 
 +
<nowiki>sudo ./blink</nowiki>
 +
 
 +
Press Control-C to exit.
 +
 
 +
You’ll find this program along with all the others mentioned here in the ''q2w'' directory under the ''examples'' directory in the wiringPi source distribution.
 +
 
 +
== Le programme Bash ==
 +
 
 +
If you don’t want to run the blink programme in C program just yet, then via BASH:
 +
 
 +
<nowiki>while true; do gpio write 1 1 ; sleep 0.5 ; gpio write 1 0 ; sleep 0.5 ; done</nowiki>
 +
 
 +
This is ''blink.sh'' in the ''q2w'' directory.
 +
 
 +
== Encore plus ==
 +
Have a look at the button.c program too – that will light up the on-board (red) LED but when you push the button it will turn it off an light up an LED connected to pin 7 (as shown above with the yellow LED) Compile and rung this this by typing:
 +
 
 +
<nowiki>make button
 +
sudo ./button</nowiki>
 +
 
 +
Or use the compilation commands as described abive.
 +
 
 +
Using this knowledge, it should be possible to use the Quick2Wire main board for some simple projects – using the on-board LED and button, and using the 8-way connector at the bottom to connect more LEDs and buttons.
   −
<nowiki></nowiki>
+
== Ne pas oublier!! ==
   −
<nowiki></nowiki>
+
N'oublier pas de retirer les cavaliers de la LED et du bouton (sur la carte principale) si vous voulez utiliser la broche 0 et 1 du GPIO de votre Raspberry Pi.
    
{{Pi-WiringPi-TRAILER}}
 
{{Pi-WiringPi-TRAILER}}
29 918

modifications

Menu de navigation