LOGIN
Jagannath Sahoo
2
Apprentice
Student
 · BhubaneswarIndia
Share
Report
Get Link
TUTORIAL

Raspberry Pi GPIO Operation through command line

From the Linux command line:

gpio -v
This prints the version.

gpio -g …
-g flag causes pin numbers to be interpreted as BCM_GPIO pin numbers

gpio mode <pin> in/out/pwm/clock/up/down/tri
Set the mode of a pin to be input, output, pwm or clock mode

gpio write <pin> 0/1
Set an output pin to high/low

gpio pwm <pin> <value>
Set the pin to a PWM value (0-1023 is supported)

gpio read <pin>
Reads and prints the logic value of the given pin 1/0

gpio awrite <pin> <value>
Analog read from the given pin. Pi has no on-board analog hardware so you need to specify an external module using the -x flag.

gpio aread <pin>
Analog value on the given pin. Pi has no on-board analog hardware so you need to specify an external module using the -x flag.

Communication Commands

gpio load spi [buffer size in KB]
For loading SPI kernel modules and default is 4KB

gpio load i2c [baud rate in Kb/sec]
For loading I2C kernel modules and default is 100Kb/sec.

gpio edge <pin> rising/falling/both/none
This enables the given pin for edge interrupt triggering on the rising, falling or both edges. (Or none which disables it)

Examples

gpio -g mode 2 out
gpio -g write 2 1

wiringPi pin numbers to set pin 2 as an output and then sets the pin to a logic 1.

gpio -g mode 2 in
gpio -g read 2

wiringPi pin numbers to set pin 2 as input.

Hope you like this… based on this I have made a simple button example. On pressing the button it will open a website over the browser…
Github link
Reference

Raspberry Pi Linux

#raspberrypi

Linux
Raspberry Pi
Contributions
Jagannath Sahoo

This is a superb, superb, tutorial, as I myself struggled with this, and can see the value for all types of engineers – as without the ability to see that gpio data, you can feel very lost quickly. Nice work. Raspberry Pi

6 likes 
Like
Award Contribution
Abhi Verma
35
Community Expert
ROBOToTHON 2017 Mentor, Electronics Engineer
 · DelhiIndia
Share
Report
Get Link

Very nice

Like
1 like 
Award Contribution
Steven Reubenstone
39
Community Expert
Mechanical Engineer & Tinkerer of Things.
 · New YorkU.S.
Share
Report
Get Link

Tutorial of the Week: Jagannath Sahoo 🎉

This is a superb, superb, tutorial, as I myself struggled with this, and can see the value for all types of engineers – as without the ability to see that gpio data, you can feel very lost quickly. Nice work.

Like
3 likes 
Award Contribution
Jagannath Sahoo
2
Apprentice
Student
 · BhubaneswarIndia
Share
Report
Get Link

Thank you So much! Steven Reubenstone

Like
0 like 
Award Contribution
Steven Reubenstone
39
Community Expert
Mechanical Engineer & Tinkerer of Things.
 · New YorkU.S.
Share
Report
Get Link

love this one

Like
2 likes 
Award Contribution
Leave a reply...
DISCOVER
CHAT
ALERTS
DISCUSSIONS
FEED
New Post
Start Project
Online Users
Share Link
Help