![]() |
|
Using GPIO pins - Printable Version +- PINE64 (https://forum.pine64.org) +-- Forum: ROCKPRO64 (https://forum.pine64.org/forumdisplay.php?fid=98) +--- Forum: General Discussion on ROCKPRO64 (https://forum.pine64.org/forumdisplay.php?fid=99) +--- Thread: Using GPIO pins (/showthread.php?tid=6419) Pages:
1
2
|
Using GPIO pins - smartdave - 08-17-2018 I am sure this is a basic question, but where can I get the python libraries for the Rockpro64. I have tried the Rock64 from Laepo's github but I do not think they are right for the pro64 board. When I did try them in Ubuntu 18.04 Bionic lxde OS build I am getting the following errors when I try to access the pins: >>>Unable to export GPIO >>>Unable to set GPIO Direction Programming is fairly new to me, but I try to google everything before asking questions Thanks Dave RE: Using GPIO pins - mcerveny - 08-19-2018 Are you running under root ? Try it from bash under root user. Code: # cd /sys/class/gpio
# ### chose pin to use - pinheader pin 11 == GPIO1_C6 == should be CPU pin 54 (1*32+2*8+6)
# echo 54 > export
# ls gpio54
active_low device direction edge power subsystem uevent value
# echo out > gpio54/direction
# echo 0 > gpio54/value
# echo 1 > gpio54/value
# echo 0 > gpio54/value
# echo 1 > gpio54/value
# echo in > gpio54/direction
# cat gpio54/value
# echo 54 > unexportRE: Using GPIO pins - smartdave - 08-19-2018 This is what I get when I run the script rock64@rockpro64:~/gpio$ sudo ./test.sh active_low device direction edge power subsystem uevent value ./test.sh: 5: ./test.sh: active_low: not found 0 rock64@rockpro64:~/gpio$ RE: Using GPIO pins - mcerveny - 08-20-2018 Oh, no. Not this way. "#" indicate interactive root prompt (but comment in scripts). Your way: Code: rock64@rockpro64:~/gpio$ sudo bash
root@rockpro64:~# cd /sys/class/gpio
root@rockpro64:/sys/class/gpio# echo 54 > export
root@rockpro64:/sys/class/gpio# ls gpio54
active_low device direction edge power subsystem uevent value
root@rockpro64:/sys/class/gpio# echo out > gpio54/direction
root@rockpro64:/sys/class/gpio# echo 0 > gpio54/value
root@rockpro64:/sys/class/gpio# echo 1 > gpio54/value
...RE: Using GPIO pins - smartdave - 08-20-2018 Thanks, I will try this later on today with a multimeter. I did try the above commands to make sure they work in the OS, and they do work in my rockpro64. Thanks ps I have done the light blinking and some other coding on the RP3 and arduinos, but getting the GPIO pins working on the Rockpro seems to be a little more involved RE: Using GPIO pins - smartdave - 08-21-2018 So I have this all figured out now. I have spoken with Allison (leapo), given her the new array values and she will be updating her python scripts to include the Rockpro64 board. Thanks for everyone's help, especially Mcerveny Until the new python scripts get updated you can use these values in the _GPIO.py file ROCK_valid_channels = [52,53,152,54,50,33,48,39,41,43,155,156,125,122,121,148,147,120,36,149,153,42,45,44,124,126,123,127] BOARD_to_ROCK = [0,0,0,52,0,53,0,152,148,0,147,54,120,50,0,33,36,0,149,48,0,39,153,41,42,0,45,43,44,155,0,156,124,125,0,122,126,121,123,0,127] BCM_to_ROCK = [43,44,52,53,152,155,156,45,42,39,48,41,124,125,148,147,124,54,120,122,123,127,33,36,149,153,121,50] RE: Using GPIO pins - Bullet64 - 09-20-2018 Thanks smartdave for your work. What I do not understand? How do I get the numbers out? http://files.pine64.org/doc/rockpro64/Rockpro64%20Pi-2%20Connector%20ver0.2.png My script Code: #!/usr/bin/env python
# Frank Mankel, 2018, LGPLv3 License
# Rock 64 GPIO Library for Python
# Thanks Allison! Thanks smartdave!
import R64.GPIO as GPIO
from time import sleep
print("Output Test R64.GPIO Module...")
# Set Variables
var_gpio_out = 52
#var_gpio_in = 18
# GPIO Setup
GPIO.setwarnings(True)
GPIO.setmode(GPIO.ROCK)
GPIO.setup(var_gpio_out, GPIO.OUT, initial=GPIO.HIGH) # Set up GPIO as an output, with an initial state of HIGH
#GPIO.setup(var_gpio_in, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Set up GPIO as an input, pullup enabled
# Test Output
print("")
print("Testing GPIO Input/Output:")
while True:
var_gpio_state = GPIO.input(var_gpio_out) # Return State of GPIO
if var_gpio_state == str(0):
GPIO.output(var_gpio_out,1) # Set GPIO to LOW
print("Output State IF : " + str(var_gpio_state)) # Print results
else:
GPIO.output(var_gpio_out,0) # Set GPIO to LOW
print("Output State ELSE: " + str(var_gpio_state))
sleep(0.5)
exit()More infos here -> https://forum.frank-mankel.org/topic/292/rockpro64-rp64-gpio (sry, only german) RE: Using GPIO pins - smartdave - 09-20-2018 What do you mean get the numbers out? I did all the conversions and came up with the following for CPU pin numbers.
RE: Using GPIO pins - Bullet64 - 09-20-2018 That's what I meant. Thank You! RE: Using GPIO pins - Bullet64 - 09-20-2018 Quick test. All pins works except pin # 19 & 26
|