From the course: Learning Arduino: Interfacing with Analog Devices

Unlock the full course today

Join today to access over 24,400 courses taught by industry experts.

Coding to control the motor directly

Coding to control the motor directly

- [Instructor] So there are two ways to driver the stepper motor. One is by using a built-in function with an Arduino, and the other one is by energizing each phase at a time manually. I'll start with the energizing each phase manually, and then we'll talk about the function in the next few videos. So, the very first thing I'm going to do is I'm going to initialize each input from the motor driver, so it's an integer motor pin one that was connected to digital pin eight in the Arduino board. I'm just going to go ahead and copy the same code, and then I'll be changing the second one to be a nine, the third one is connected to 10, and then finally the fourth one was connected to 11. Okay. I'm going to initialize the delay time here, so I'm going to go with integer delay time to be two, for example, and then we'll change that later in the code. In the void setup I'm going to set the pin mode for each of the motor pins to be as an output. So, pin mode for motor pin one is output, and I'll…

Contents