Code RPI-c-act 101
En utilisant Geany⚓
Version Pi - Langage c⚓
1
/**********************************************************************
2
* Filename : Blink.c
3
* Description : Basic usage of GPIO. Let led blink.
4
* auther : www.freenove.com
5
* modification: 2019/12/26
6
**********************************************************************/
7
8
9
10
//define the led pin number
11
12
void main(void)
13
{
14
printf("Program is starting ... \n");
15
16
wiringPiSetup(); //Initialize wiringPi.
17
18
pinMode(ledPin, OUTPUT);//Set the pin mode
19
printf("Using pin%d\n",ledPin); //Output information on terminal
20
while(1){
21
digitalWrite(ledPin, HIGH); //Make GPIO output HIGH level
22
printf("led turned on >>>\n"); //Output information on terminal
23
delay(1000); //Wait for 1 second
24
digitalWrite(ledPin, LOW); //Make GPIO output LOW level
25
printf("led turned off <<<\n"); //Output information on terminal
26
delay(1000); //Wait for 1 second
27
}
28
}
29
Ouvrir une console pour compiler le code avec la librairie wiringPi. Vous devez vous déplacer dans le dossier qui contient le fichier Blink.c
. Normalement, il s'agit de home/pi/Documents/FRN_RF/Code/C_Code/01.1.1_Blink
. Pour obtenir de chemin, ouvrir le gestionnaire de fichier, descendre dans l'arborescence, puis, copier le chemin.
Ensuite , dans la console tapez cd espace
clic...droit Coller
.
1
gcc Blink.c -o Blink -lwiringPi
Puis exécuter le programme.
1
sudo ./Blink