After installing wiringPi library, we can use it to manipulate the GPIO, the light emitting diode lights up as sacred experimentation as "Hello World" herein, this comes in the driving LED blinks raspberry.
1. Hardware connection
LED light-emitting diode cathode connected to the GND raspberry pie, LED current limiting resistor is connected to a positive electrode 220 is connected to the pin 11 ohms raspberry School.
Circuit connection is shown below:
Remote login to the Raspberry Pi, enter "gpio readall" in the terminal, you can get to the pin correspondence, we can see that the Raspberry Pi board pin header 11 pin corresponds wiringPi library 0 pins.
2. The code for a line terminal LED flashes
wiringPi library built a gpio function, which can be accessed directly from the terminal GPIO, without writing any code. In a terminal "gpio -h" available to application notes gpio function:
We enter the following command in the terminal:
gpio blink 0
We can see the LED starts blinking.
Press the keyboard "Ctrl + C" to exit.
4. wiringPi programming LED flashes
Create a new file named blink.c the contents as follows:
#include <wiringPi.h>
int main(void)
{
wiringPiSetup();
pinMode(0, OUTPUT);
while(1)
{
digitalWrite(0, HIGH);
delay(500);
digitalWrite(0, LOW);
delay(500);
}
return 0;
}
If written in the windows, you need to download files to the Raspberry Pi. Gcc command in the input files in the current directory to compile the program:
gcc -Wall -o blink blink.c -lwiringPi
Then enter the compiled program command as follows:
sudo ./blink
LED flashes can be seen, we can change the delay time to control the LED blinking frequency. By "Ctrl + C" end of the program.
Focus on micro-channel public number: TonyCode
the Arduino learning exchange group: 868 283 450
More, I welcome the attention of the public number. Sweep the micro-channel to follow the Fanger Wei code: