|
Post by Carl Gundel on Apr 15, 2019 22:29:27 GMT -5
It seems that the GPIO features of the Raspberry Pi are manipulated by treating them as part of the file system. Pretty clever, huh? Anyone here already familiar with this? I'm hoping to score a volunteer for an example. -Carl
|
|
|
Post by Chris Iverson on Apr 15, 2019 22:32:12 GMT -5
I'd have to do some refreshing, since my small electronics work was mainly with an Arduino, but with 3 Pi3Bs' and 1 Pi3B+, I should probably be able to assist in any way.
|
|
|
Post by Carl Gundel on Apr 16, 2019 7:33:22 GMT -5
I'd have to do some refreshing, since my small electronics work was mainly with an Arduino, but with 3 Pi3Bs' and 1 Pi3B+, I should probably be able to assist in any way. This article looks like good information, but it almost seems like the GPIO pins are controlled by only from the terminal window. So, I'm guessing I will need to "shell" out from LB for each read and write of GPIO. Seems inefficient. codefoster.com/pi-basicgpio/
|
|
|
Post by Carl Gundel on Apr 16, 2019 8:23:57 GMT -5
Okay, there is some more information here. from raspberrypi.znix.com/hipidocs/topic_gpiodev.htmSeems important that before any user can use GPIO on the pi that the user must first belong to the gpio group. Or else the app must run as root.
|
|
|
Post by Chris Iverson on Apr 17, 2019 0:36:07 GMT -5
Two things.
One, the default user on the Pi(pi) is a member of the gpio group by default:
pi@rpi3b:~ $ groups pi adm dialout cdrom sudo audio video plugdev games users input netdev gpio i2c spi
Unless you're running on a custom user account, switching to root isn't necessary. (Heck, you're better off switching to the pi account than the root account, or just adding your custom account to the gpio group.) Definitely good to know, but for the most part, this shouldn't be an issue. (Good thing to keep in mind, though.)
Two, it's not a shell interface, it's a file interface(much like anything else in Linux). LB's built-in file commands work just fine, as long as you make sure to NOT output newlines(outputting newlines causes it to not work properly, as the only values it expects are single-line.)
Oh, and make sure you wait a bit after enabling a GPIO line, or LB may try to access the line before it's ready, and fail.
open "/sys/class/gpio/export" for output as #file print #file, "4"; close #file
timer 100, [continue] wait
[continue] timer 0
open "/sys/class/gpio/gpio4/direction" for output as #file print #file, "out"; close #file
open "/sys/class/gpio/gpio4/value" for output as #file print #file, "1"; close #file
This worked just fine to turn on an LED I wired onto GPIO 4(header pin 7).
EDIT: Oh, and just as that page you linked to earlier said, the following is equivalent to the above, and also works for me:
open "/sys/class/gpio/export" for output as #file print #file, "4"; close #file
timer 100, [continue] wait
[continue] timer 0
open "/sys/class/gpio/gpio4/direction" for output as #file print #file, "high"; close #file
|
|
|
Post by Carl Gundel on Apr 18, 2019 9:17:44 GMT -5
<snip> This worked just fine to turn on an LED I wired onto GPIO 4(header pin 7). EDIT: Oh, and just as that page you linked to earlier said, the following is equivalent to the above, and also works for me: That's so great thanks. Is it possible to show a photo of your setup doing this so that I can post a link to it from Facebook and Twitter saying something like "First Liberty BASIC use of GPIO on Raspberry Pi!"
|
|
|
Post by Chris Iverson on Apr 18, 2019 23:05:24 GMT -5
Here you go! LED off and on. imgur.com/a/AvhlnzpReally should've done this on the smaller Pi touchscreen I have, it would've been way easier to arrange, and probably looked neater. Oh well, that's what I get for not planning things out
|
|
|
Post by Carl Gundel on Apr 19, 2019 8:38:25 GMT -5
Here you go! LED off and on. imgur.com/a/AvhlnzpReally should've done this on the smaller Pi touchscreen I have, it would've been way easier to arrange, and probably looked neater. Oh well, that's what I get for not planning things out Thanks Chris!
|
|