Preparing to write some tutorials on getting started with Raspberry Pi, this tutorial uses C language for teaching. It roughly involves the control of the GPIO pins of the Raspberry Pi, an introduction to Raspberry Pi, and specific examples of using GPIO pins. It is mainly aimed at beginners of Raspberry Pi.
We use the wiringPi library, so we only look at wiringPi coding, as for BCM coding, we don’t need to worry about it for now.
For example: if we want to control physical pin 8, its corresponding wiringPi code is 15 (the corresponding BCM code is 14). The code using the wiringPi library is as follows:
#include <wiringPi.h>
#include <stdio.h>
int main() {
// Initialize
wiringPiSetup();
// Set mode to OUTPUT
pinMode(15, OUTPUT);
// Output high level
digitalWrite(15, HIGH);
// Output low level
digitalWrite(15, LOW);
return 0;
}
What can Raspberry Pi be used for? Raspberry Pi can be used as a main control board to control whatever you want, and it does not require too much hardware knowledge. Additionally, Raspberry Pi is also a computer with a Linux system, which can be used to do many things. I have personally made quite a few things, such as controlling a car with Raspberry Pi, how to use ultrasonic distance measurement with Raspberry Pi, how to control servos with Raspberry Pi, and multi-degree-of-freedom robotic arms, etc. If you are interested, feel free to join our group. QQ group: 253222403.
How to use these function libraries? I have uploaded a document here.
Link: https://pan.baidu.com/s/1BjX6PmdKaRUAOHz1r1nvgw
Extraction code: do8m
Welcome to follow our public account, my knowledge and ability are limited, if there are any errors in the article, please feel free to give me feedback or leave a message, thank you very much!