Basic advice

Very basic question from a beginner. I have salvaged a toy 3.3v motor from a cheap robot toy, coupled it with a TIP122 transistor, diode and resistor and have written a very basic sketch to turn it on and off. This works fine. some questions: How do I get the motor to go backwards? I guess I can swap the leads around but how to I do that programatically? I got another motor from the robot (also with handy wheels and gears) so I'm planning to make a little car. I presume there is no problem running two little motors using this simple transistor set up. I don't have the specs of the motors but they are only tiny (ran off 2 AA batteries in the toy) so I guess they don't draw much current. Thanks in anticipation

Alan

I guess I can swap the leads around but how to I do that programatically?

You could use a DPDT relay, or you could use an H-bridge.

You can also use PWM (analogWrite) to vary the speed.