Charging lithium and NiMH batteries is more involved than supplying voltage. You have to monitor the correct ending conditions, some of which (-dV/dT ...) are nasty.
Chagrin's comment is wrong -- when full, a NiMH battery will have a negative voltage change for an increase in current. That's how you tell they are full -- when the temperature rises more than 3*C or so in some short time period (2 or 3 minutes), and the terminal voltage falls.
The usual charging profile is 1.55 volts per cell, then terminate the charge when the temperature rises faster than the cutoff, or the voltage drops more than a few millivolts per cell. To play it safe, pick a smaller value, say, 1.50 volts per cell, and reduce the charging current (use a PWM pin to control a transistor that's supplying current to the batteries) whenever the voltage rises. The OP can measure the voltage with a voltage divider -- be sure to use precision resistors.