I am following a guide on controlling servos and when I run the code it comes up with an error. I have no idea what is happening. Can someone help?
here is the link to the guide [Controlling Standard Servos with Raspberry Pi - Tutorial Australia]
Welcome to the forum
Thanks for sharing a link to the guide you were following along with. I’ve noticed a few small differences in your code to the example in the guide. The main one is that your program does not have an infinite loop, so when you run the code it will execute top to bottom once and then halt.
The example code has a 2 second wait in the loop and several angles, so that the servo will move, then pause briefly, before moving back the other way.
You also seem to have declared you are using GPIO 3 rather than GPIO 18.
Please take a photo of how everything is physically connected and attach it in this thread. We can double-check your wiring for small errors that might have caused the issues you’re having.
first of all, thank you for helping. the code on the website works but I want it to only do it turn once.
I have moved my wire from GPIO 3 to GPIO 18 to avoid more problems.