View: 1515|Reply: 2

OPi.GPIO error

[Copy link]

9

threads

12

posts

117

credits

Registered member

Rank: 2

credits
117
Published in 2023-6-9 05:52:20 | Show all floors |Read mode
i am using a orange pi 3 lts and i want to use my gpio pins and i do a nano ledBlink.py and then i do small program useing the OPi.GPİO library and i write a program that just turns HIGH AND LOW 4 time but i keep geting this error it i been trying to fix this error for over a 4 months but i can fix it i would be very happy if one help me and know there is PYa20 library i can also use but i realy want to use OPi.GPIO  
import OPi.GPIO as GPIO here is the ledBlink program import time                                                                                                                GPIO.setmode(GPIO.BOARD)LED_PIN = 7GPIO.setwarnings(False)GPIO.setup(LED_PIN, GPIO.OUT)try:    while True:        GPIO.output(LED_PIN, GPIO.TRUE)        time.sleep(1)        GPIO.output(LED_PIN, GPIO.FALSE)        time.sleep(1)except KeyboardInterrupt:                                                                                                         GPIO.cleanup()


  File "ledBlink.py", line 7, in <module>    GPIO.setup(LED_PIN, GPIO.OUT)  File "/usr/local/lib/python3.7/site-packages/OPi.GPIO-0.5.3-py3.7.egg/OPi/GPIO.py", line 482, in setup    sysfs.direction(pin, direction)  File "/usr/local/lib/python3.7/site-packages/OPi.GPIO-0.5.3-py3.7.egg/OPi/sysfs.py", line 56, in direction    fp.write("out")OSError: [Errno 22] Invalid argumentyusufsait@orangepi3-lts:~$                                        and here is the error

1

threads

3

posts

21

credits

Novice

Rank: 1

credits
21
Published in 2023-6-10 23:58:54 | Show all floors

I am a newer on Orange Pi 5 and do not own an Orange Pi 3.
Please reference to: https://github.com/orangepi-xunlong/wiringOP
But code in above web page dose not support Orange Pi 5 at this moment.
Therefor, I modified your code as below and have no test.
Hope these information can help you.


import OPi.GPIO as GPIO  # here is the led Blink program
import time

GPIO.setboard(GPIO.OPi3)
GPIO.setmode(GPIO.BOARD)
LED_PIN = 7
#GPIO.setwarnings(False)

GPIO.setup(LED_PIN, GPIO.OUT)
try:
    while True:
        GPIO.output(LED_PIN, 1)
        time.sleep(1)
        GPIO.output(LED_PIN, 0)
        time.sleep(1)
        
except KeyboardInterrupt:
    GPIO.output(LED_PIN, 0)
    GPIO.cleanup()



9

threads

12

posts

117

credits

Registered member

Rank: 2

credits
117
 Author| Published in 2023-6-11 22:46:18 | Show all floors
thank you have a lovely day
You need to log in before you can reply login | Register

Points Rule

Quick reply Top Return list