0

I'm building a project for my Physical Computing class that involves 4 vibration motors for varied haptic feedback based on serial input via analogRead. I have each coming out of their own pin and assigned to conditionals.

I'm wondering:

  • how do i control the PWM of each individual motor?
  • assuming I need an external power source for the motors, do I need to have a diode and transistor in between each motor and the ground?

Thanks in advance - I'm still learning but definitely looking forward to taking Part II next semester!

3
  1. You can control motor PWM by using AnalogWrite() feature. Arduino Mini is equipped with 6 PWM pin, so you can use 1 PWM pin for each of you motor. Check here about more information on AnalogWrite, and here about Arduino Mini
  2. This is the circuit if you want to use external power source. Normally, I use 1k ohm resistor, I'm sure there are someone out there that knows the exact formula.

schematic

simulate this circuit – Schematic created using CircuitLab

  • Why specifically use a zener diode as a flyback? Can't a regular diode (granted it can handle the voltage) do the trick? Is there a specific advantage of using a zener diode over a normal diode? – Len Dec 8 '16 at 9:22
  • 1
    Sure regular diode will also works, I didn't mention anything about specifically using zener diode – dhimaspw Dec 8 '16 at 9:31
  • Hi - thanks for the help. I'm pretty solid on the physical routing now, at this point, its more the code I'm worried about. I'm guessing I can use an elseif statement? So for example if I have irPin1 = analogread(irVal1) to set the analogRead for the IR sensor I'm using, and then: ' if (irVal1 < 400){ digitalWrite(vibePin1 = HIGH); } else(){ digitalWrite(vibePin1 = LOW); }' – Nick Dec 8 '16 at 15:12
  • From there, how would I distribute PWM values to each sensor? I'm assuming that I'd be creating a pwmVal variable to store something? AnalogWrite(pwmVal = 30) or something like that? Assuming it goes 0-255. – Nick Dec 8 '16 at 15:15
  • 1
    @Nick if there are new question, in my opinion you should post another question or edit the original instead of asking in comment section. – dhimaspw Dec 9 '16 at 1:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.