I face a problem.
File B has import from gpiozero which controls LED. The default GPIO mode is a BCM. While in file A, it allows NFC reader to read card which imports MFRC522. However, MFRC522 gpio mode is set to BOARD.
I imported file B into file A. I called the function in file B. However when I attempt to run file A, it gave me this error.
Traceback (most recent call last): File "NFC_Security.py", line 53, in <module> LEDs.authorised() File "/home/pi/Garage_Parking/rpi_components/LEDs.py", line 13, in authorised greenLed = LED(6) # Green LED lights up when the user is authorised File "/usr/lib/python2.7/dist-packages/gpiozero/devices.py", line 134, in __call__ self = super(GPIOMeta, cls).__call__(*args, **kwargs) File "/usr/lib/python2.7/dist-packages/gpiozero/output_devices.py", line 131, in __init__ super(DigitalOutputDevice, self).__init__(pin, active_high, initial_value) File "/usr/lib/python2.7/dist-packages/gpiozero/output_devices.py", line 41, in __init__ super(OutputDevice, self).__init__(pin) File "/usr/lib/python2.7/dist-packages/gpiozero/mixins.py", line 69, in __init__ super(SourceMixin, self).__init__(*args, **kwargs) File "/usr/lib/python2.7/dist-packages/gpiozero/devices.py", line 381, in __init__ pin = pin_factory(pin) File "/usr/lib/python2.7/dist-packages/gpiozero/pins/rpigpio.py", line 82, in __new__ GPIO.setmode(GPIO.BCM) ValueError: A different mode has already been set! Exception AttributeError: "'LED' object has no attribute '_controller'" in <bound method LED.__del__ of <gpiozero.LED object closed>> ignored
Is there any way I can overcome this error? How can I call the function in file B so that I can run it in file A? I appreciate a lot. Thank You.