Controlling a motor! Basic n00b questions (include a non-programming one)

Hey guys!

So it's been many years since I touched any eletronic stuff but I missed it dearly.. the idea of building a robot from scratch always been my dream... :slight_smile: I already forgot a lot of basic stuff so bear with me :confused:

I decided to play with what I have in stock; an arduino uno and arduino uno motor shield rev 3 (I got them a year ago for a project that I eventually found another solution to...)

ANYWAY!

I was googling instructions (as well as electronics tutorials despite the fact I have a degree in mechatronics - father time erased most of it!) and I found some basic tutorial on how to use a motor shield. So I connected the motor shield on top of the uno and then additionally connected a stepper motor where the tutorial told me to (I think it's a stepper motor because it only rotates in certain degrees). Here's the lovely setup: (ignore the poor soldering debris in the background and the nail file I'm using because I don't have a small screw :grin: )

I tried to run the script and the motor was activated, but I wasn't really sure what's going on and how do I truly "control" it. Here's the script that I'm currently using:

int A = 3;
int B = 4;

void setup()
{
pinMode(A, OUTPUT);
pinMode(B, OUTPUT);
}

void loop()
{
digitalWrite(A,HIGH);
digitalWrite(B,HIGH);
}

If A and B are the same the motor starts acting out: internally something seems to move or vibrate but the shaft itself isn't, and then after 5-10 seconds it stops altogether. When A and B are different it works, but it always turns in the same direction no matter what I choose A and B to be.

Questions:

  1. Why is the motor acting out when A and B are the same number?
  2. How can I get it to spin in the other direction?
  3. How do I control its speed? With analogwrite?
  4. More basic question: Do I really have to upload the script every time I want to change the motor's speed? Isn't there a simpler interface where I can just click and it changes the motor's speed?
  5. How can I be sure it's a stepper motor?
  1. More basic question: Do I really have to upload the script every time I want to change the motor's speed? Isn't there a simpler interface where I can just click and it changes the motor's speed?

You could write a graphical interface on the PC using a suitable language and pass the speed commands to the Arduino to act on, or you could add a couple of pushbuttons to the Arduino and use them to control the speed.

  1. How can I be sure it's a stepper motor?

It is not a stepper motor. A stepper would have more terminals. It looks like a plain permanent magnet motor. Apply current to the terminals and it moves. That raises the question as to how it is powered. The Arduino cannot itself supply enough current to run a motor of that size. Add an external power supply for the motor before you damage the Uno if you have not already done so.

A) That is not a stepper motor. A stepper will have at least four terminals. That is a brushed DC motor.

B) Your code is not code for a stepper motor.

I think the problem might be the "Enable" pin, which you are not setting. Read the documents for the motor driver or use a library and read the examples for the library.

I think that the motors are now backpowered through the 5volt regulator of the Arduino.

Use a 9-12volt motor supply on the power connections of the motor board.
Leo..

I decided to watch some basic tutorials, seems like I'm lacking basic knowledge.

About the source of energy: The motor came with the original sparkfun kit I bought 5 years ago and a 3V battery made it spin super fast.

The motor came with the original sparkfun kit I bought 5 years ago and a 3V battery made it spin super fast.

OK, but how is it powered in your current project ?

From the Arduino 5V or 3.3V pins (wrong !) or from an external power source (correct)

External power source. Ignore the image; I plugged in a 12V power adapter.

I plugged in a 12V power adapter.

Where to ?