sleeptime = int(input("How long do you want me to go forward, turn, etc? Reccomended value is 3. ")) #This is how many seconds you want the robot to do each thing (go forward, etc) #This is the setup code. from gpiozero import Robot from time import sleep robot = Robot((2, 3), (23, 24)) newcommand = "kid2kidtech" commands = ["done"] pop = "kid2kidtech" print("Welcome to the Kid2KidTech Robot Programmer!") #This code repeats until you type in go. It detects what you typed in and ads it to a list. while newcommand != "go": newcommand = input("Type in your new command. ") if newcommand == "forward": commands.insert(1, "forward") print("Added forward. ") elif newcommand == "backward": commands.insert(1, "backward") print("Added backward. ") elif newcommand == "left": commands.insert(1, "left") print("Added left. ") elif newcommand == "right": commands.insert(1, "right") print("Added right. ") elif newcommand == "program": print("Here is your program:") print(commands) print("Good job!") elif newcommand == "go": print("Starting...") else: print("Unrecognized command. Please try typing forward, backward,left, right, or, to look at your program, type program. Type go to start robot.") print("Compiled program. Running your commands.") #This code reads the last item in the list (the first one you typed in) and does what it says. while pop != "done": pop = commands.pop() if pop == "forward": print("Going forward") robot.forward() sleep(sleeptime) elif pop == "backward": print("Going backward") robot.backward() sleep(sleeptime) elif pop == "left": print("Going left") robot.left() sleep(sleeptime) elif pop == "right": print("Going right") robot.right() sleep(sleeptime) elif pop == "done": print("All done! Restart the program to do it again.") else: print("There is an error in the code. A list item does not match instrucions.") print("Oh, and visit kid2kidtech.com for more cool tutorials!")