Running two dc motors and controlling it

Hello everyone!
After reading a lot of posts here and trying to find a solution for my problem I learned that people here are very helpful. I could not find an exact solution and thus thought of creating an account and posting my question here. I hope you guys will help me!

Basically I have a project due and am completely new to the topic of motors and arduino. I just bought one arduino UNO.
I have two dc motors of 3V and 6V each (One is like a driving motor and the other acts like a tachometer). I have glued heir shafts together so when one rotates, it rotates the other. What am planning to do here is that I power up my 6V motor so both of them starts rotating. This is the first part I need some code for this and connections ( I have no idea about the connections but if someone shows me some preliminary stuff I can work it out).

Second, when the motors are up and running rotating the shafts. What I basically do is put my finger on the shaft trying to slow the motion. Now the voltage from my source is a constant right. So i need to put a PID control such that when i put a force to stop the shafts the controller should increase the source voltage in order to increase the RPM.
A code would be required for this.
If you guys could give me a basic start up for this it would be very helpful.
I don't have time on my side to explore and find out stuff and that's why i seek direct help for my problem. =(

Awaiting positive responses
Thanks a tonne!

Okay, off the top of my head here is one way of doing this. (Be sure to confirm with someone else though)

  • Turn on the 6V motor at full speed and measure the voltage between 3V motor leads.
  • If it's equal or less than, say 2.2V - give one lead maybe 2.5V and connect the other to an analog pin through a 20k resistor. Remember to connect the grounds too.
  • Make sure [ref_voltage] +/- [max_variance] is between 0V and 5V. You can even use Arduino's 3.3V out should the max_variance be less than 1.7V. However if it is too low, your accuracy will be affected. (ADC resolution: 10bit)
  • Use a motor controller to drive the 6V motor with PWM.
  • Get readings for CW, CCW at required speeds (ranges) and control PWM duty cycle accordingly.
  • has pretty much everything you need to write the program.

Probably you will need to smooth out the input from motor.