TIP: Click on subject to list as thread! ANSI
echo: rberrypi
to: ALL
from: R.WIESER
date: 2019-11-15 20:49:00
subject: Accessing GPIO pins using

Hello all,

I'm trying to put some GPIO pin related code into a class object, when I
realized that when I, while initializing the object, use

import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)

I could be overriding a previously set mode, or my setting could be
overruled by a later on in the code.  Which would mean that either my object
or some other code would be referencing the wrong GPIO pins. :-(

I already tried

import RPi.GPIO as GPIO1
GPIO1.setmode(GPIO1.BCM)
import RPi.GPIO as GPIO2
GPIO2.setmode(GPIO2.BOARD)

, but that threw an error on the second ".setmode()"

So my question is:
Can I use two different pinnumbering schemes at the same time ? And if so,
how ?

Maybe by instanciating RPi.GPIO as an object (making all settings local to
it) ?

Regards,
Rudy Wieser

--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)

SOURCE: echomail via QWK@docsplace.org

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.