Motors for raspberry pi robot not working

To prevent the key character from displaying you need to add a call to noecho(). See: curses — Terminal handling for character-cell displays — Python 3.11.5 documentation.

However, the fact that you see the characters does indicate that the key is being detected. You can match the characters you are seeing to the movement constants (KEY_UP, etc) to confirm that the keys are doing what you think they are doing. You can add simple debug output statements to console to find out how much further the code is getting - at least until you confirm that you are executing the code up to the ‘action()’ line.

(Note: I come from a different language, where that line should be action.value(), not action(). Python might be different, but it’s worth checking.)

You can debug your code by replacing the calls to the robot functions with calls to your own functions that display a message confirming that the action process is being called. If that works OK then you know the problem is in the various robot.whatever functions.

The step after that would then be to find a robot example script that includes a minimum of other code. If that fails then you likely have a wiring problem. For instance: 2. Basic Recipes — GPIO Zero 1.6.2 Documentation

What are the pin connections you are using from the Pi to the driver? It is difficult to identify pin connections from the image, so a list of how you have it wired would be useful. Be sure to include the power and ground connections.

edit/ get() returns the value part of the key-value pair, not the tuple, so you can ignore the comment about a possible problem with the action() line /edit

1 Like