Is this vibration motor circuit correct?

I plan on turning them on sequentially. Do I need a diode? 

// Define motor control pins
const int threePin = 3;  // Pin connected to "Three" motor's control transistor or driver
const int fourPin = 4;   // Pin connected to "Four" motor's control transistor or driver
const int fivePin = 5;   // Pin connected to "Five" motor's control transistor or driver
const int sixPin = 6;    // Pin connected to "Six" motor's control transistor or driver
const int sevenPin = 7;  // Pin connected to "Seven" motor's control transistor or driver
const int eightPin = 8;  // Pin connected to "Eight" motor's control transistor or driver

void setup() {
  Serial.begin(9600);
  // Initialize digital pins as outputs
  pinMode(threePin, OUTPUT);
  pinMode(fourPin, OUTPUT);
  pinMode(fivePin, OUTPUT);
  pinMode(sixPin, OUTPUT);
  pinMode(sevenPin, OUTPUT);
  pinMode(eightPin, OUTPUT);

  // Ensure all motors are off initially
  digitalWrite(threePin, LOW);
  digitalWrite(fourPin, LOW);
  digitalWrite(fivePin, LOW);
  digitalWrite(sixPin, LOW);
  digitalWrite(sevenPin, LOW);
  digitalWrite(eightPin, LOW);
}

void loop() {
  // Sequentially activate each motor for testing
  activateMotor(threePin);  // Activate motor connected to the "Three" pin
  activateMotor(fourPin);   // Activate motor connected to the "Four" pin
  activateMotor(fivePin);   // Activate motor connected to the "Five" pin
  activateMotor(sixPin);    // Activate motor connected to the "Six" pin
  activateMotor(sevenPin);  // Activate motor connected to the "Seven" pin
  activateMotor(eightPin);  // Activate motor connected to the "Eight" pin
}

// Function to activate a motor at the specified pin
void activateMotor(int motorPin) {
  Serial.print("Activating motor on pin: ");
  Serial.println(motorPin);
  digitalWrite(motorPin, HIGH); // Turn motor on
  delay(1000);                  // Keep it on for 1 second
  digitalWrite(motorPin, LOW);  // Turn motor off
  delay(500);                   // Wait for 0.5 seconds before next activation
}

Yes you need a diode.
Your wiring diagram has a few mistakes. The base resistor isn't connected.
You can't power 6 of those motors from the Uno 5V output, you will need a separate power supply
Which transistor do you plan on using?

1 Like

Is this how your motors are connected?

Thank you for your reply.

It is a 2222A331 transistor

Can the separate power supply be the one from the arduino?

Oh, no, that's not how they are connected, but thank you for the diagram, I will try it like that

That is an INPUT NOT and OUTPUT
You will need a 5V 1A power supply, maybe a plug in wall adaptor type.

ohh alright,good to know. I'm very beginner on this

Thanks so much for the suggestion, will look that up

Like one of these

1 Like

Does the transistor look like this with 2222A on it

Did I see a DC motor driver module suggested as a driver for DC vibration motors?

ohh i think I have one

maybe

What I want to know if it is a 2222 or a 3904 because the pins are in different orders

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.