Created
December 27, 2017 17:50
-
-
Save quonic/32d56f1c42bc0a5e5752cd0232aa657c to your computer and use it in GitHub Desktop.
Talk GPIO via Powershell Core
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Open-GPIOPin ([int]$Pin,[ValidateSet('in','out')][string]$Mode) { | |
| [string]$Pin | Out-File -FilePath "/sys/class/gpio/export" -NoNewline | |
| $Mode | Out-File -FilePath "/sys/class/gpio/gpio$Pin/direction" -NoNewline | |
| } | |
| function Send-GPIOBit ([int]$Pin,[ValidateRange(0,1)][int]$Bit) { | |
| $Bit | Out-File -FilePath "/sys/class/gpio/gpio$Pin/value" -NoNewline | |
| } | |
| function Receive-GPIOBit ([int]$Pin) { | |
| return (Get-Content -Path "/sys/class/gpio/gpio$Pin/value") | |
| } | |
| function Close-GPIOPin ([int]$Pin,[ValidateSet('in','out')][string]$Mode) { | |
| [string]$Pin | Out-File -FilePath "/sys/class/gpio/unexport" -NoNewline | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment