Raspberry Pi 4B C language LED lighting emitting diode (LED lamp)
1. Raspberry Pi GPIO pin 40Pin table
2.wiringPi database update
Open a terminal and type: gpio readall If an error message occurs, perform the following steps to update wiringPi
(The latest release of raspberry pie 4B in burning buster after the official system, if used directly gpio readall GPIO to see an error occurs)
cd /tmp wget https://project-downloads.drogon.net/wiringpi-latest.deb sudo dpkg -i wiringpi-latest.deb
Execution: gpio -v view the version number version 2.52
gpio readall View Pin Description
3. The circuit connection
Circuit is relatively simple, to increase a current limiting resistor (200 [Omega])
Physical connection diagram
4. Write a program
Source Code:
1 #include <stdio.h> 2 #include <wiringPi.h> 3 4 int main(void) 5 { 6 7 int LED = 8; 8 wiringPiSetup(); 9 10 pinMode(LED,OUTPUT); 11 12 int number = 10; 13 int count = 0; 14 while(count <10) 15 { 16 17 printf("LED:%d is on\n",LED); 18 digitalWrite(LED,HIGH); 19 delay(500); 20 21 printf("LED:%d is off\n",LED); 22 digitalWrite(LED,LOW); 23 delay(500); 24 25 count++; 26 } 27 28 return 0; 29 }
GCC compiler:
gcc -o led -lwiringPi after led.c compiler will generate a file led
./led execution program: See breadboard then alternately flashing light emitting diode