Support Forum

Share your projects and post your questions

Register   or   Sign In
The Forum

GPIO.setmode(GPIO.BOARD) Error

3225 Views - Created 19/05/2020


Posted by:

user387283 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.


Posted by:

andrew Avatar

United Kingdom

andrew Twitter  andrew Website  


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

Sign in to post your reply

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.