About Us Knowledge Base Community Forum Electronics Toolbox FAQ Shipping & Delivery

Community Forum

Share your projects and post your questions

Search
Register or Sign In
Forum

GPIO.setmode(GPIO.BOARD) Error

271 Views - Created 19/05/2020

19/05/2020

Posted by:
user387283

Users Avatar

When creating a new instance of the Servo class an error is being thrown. It happens on line 142 where GPIO.setmode(GPIO.BOARD) is being called. 

ValueError: A different mode has already been set!

I am confused as to why this is happening since in my code I am not even using the RPi.GPIO class and therefore not setting the mode for the GPIO before this instance.

19/05/2020

Posted by:
andrew

Users Avatar

Location:
United Kingdom

Users Twitter  Users Website  

Hello

The error you are getting normally occurs if the GPIO mode has already been set by another program on the Raspberry Pi.  I am not sure why you are getting the error if you have not used the RPi.GPIO class elsewhere.

I have updated the Servo Pi library to make it check to see if the GPIO mode has already been set and if it has, use the selected GPIO mode.  Hopefully this will fix the error that you are getting.

You can download a new version of the Servo Pi library from our GitHub repository at https://github.com/abelectronicsuk/ABElectronics_Python_Libraries/blob/master/ServoPi/ServoPi.py

 

AB Electronics UK Tech Support

Note: documents in Portable Document Format (PDF) require Adobe Acrobat Reader 5.0 or higher to view, download Adobe Acrobat Reader or other PDF reading software for your computer or mobile device.