gpio_control_from_command_line
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
gpio_control_from_command_line [2017/01/22 13:51] – [Install] walkeradmin | gpio_control_from_command_line [2023/03/09 22:35] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 7: | Line 7: | ||
\\ | \\ | ||
\\ | \\ | ||
+ | |||
+ | ---- | ||
+ | |||
==== Install WiringPi==== | ==== Install WiringPi==== | ||
\\ | \\ | ||
Line 14: | Line 17: | ||
\\ | \\ | ||
sudo apt-get install wiringpi | sudo apt-get install wiringpi | ||
- | \\ | ||
\\ | \\ | ||
Once installed, you will have access to the gpio utility. | Once installed, you will have access to the gpio utility. | ||
\\ | \\ | ||
\\ | \\ | ||
+ | As a quick test, from the command line type: | ||
+ | \\ | ||
+ | \\ | ||
+ | gpio -v | ||
+ | \\ | ||
+ | This will display the version of WiringPi you have installed. | ||
+ | \\ | ||
+ | < | ||
+ | gpio version: 2.32 | ||
+ | Copyright (c) 2012-2015 Gordon Henderson | ||
+ | This is free software with ABSOLUTELY NO WARRANTY. | ||
+ | For details type: gpio -warranty | ||
+ | Unable to determine hardware version. I see: Hardware | ||
+ | , | ||
+ | - expecting BCM2708 or BCM2709. | ||
+ | If this is a genuine Raspberry Pi then please report this | ||
+ | to projects@drogon.net. If this is not a Raspberry Pi then you | ||
+ | are on your own as wiringPi is designed to support the | ||
+ | Raspberry Pi ONLY. | ||
+ | </ | ||
+ | \\ | ||
+ | \\ | ||
+ | Another test, and something you can use a lot to check the status of the gpio is the </color red> | ||
+ | \\ | ||
+ | \\ | ||
+ | gpio readall | ||
+ | \\ | ||
+ | This will give an output similar to below (This output is from a Pi Zero v1.3) | ||
+ | \\ | ||
+ | \\ | ||
+ | < | ||
+ | | ||
+ | | BCM | wPi | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | BCM | wPi | | ||
+ | | ||
+ | </ | ||
+ | \\ | ||
+ | It can be seen that this Pi has GPIO set to OUT and some to IN. I am using the Pi as a clock, so these are the lines going to my LED display. | ||
+ | \\ | ||
+ | \\ | ||
---- | ---- | ||
+ | ==== Using gpio command ==== | ||
+ | \\ | ||
+ | \\ | ||
+ | Before looking at the commands, there is a switch I want to talk about, this is <color red> | ||
+ | \\ | ||
+ | \\ | ||
+ | To set the function of the GPIO pin, use <color red>gpio -g mode</ | ||
+ | \\ | ||
+ | \\ | ||
+ | using BCM number | ||
+ | gpio -g mode 18 out - Sets GPIO18 to OUTput mode (GPIO18 is physical pin 12) | ||
+ | | ||
+ | using pin instead of bcm | ||
+ | gpio mode 12 out - Sets GPIO18 to OUTput mode (GPIO18 is physical pin 12) | ||
+ | | ||
+ | Modes are In, Out, PWM, Up, Down and Tri. | ||
+ | \\ | ||
+ | \\ | ||
+ | Set GPIO pin to 1 or 0 | ||
+ | \\ | ||
+ | \\ | ||
+ | gpio -g write 18 0 - sets GPIO18 to a zero. | ||
+ | | ||
+ | gpio -g write 18 1 - sets GPIO18 to a one. | ||
+ | \\ | ||
+ | \\ | ||
+ | ---- | ||
+ | | ||
gpio_control_from_command_line.txt · Last modified: 2023/03/09 22:35 by 127.0.0.1