From the course: Learning Arduino: Interfacing with Analog Devices

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Coding the joystick and motor

Coding the joystick and motor

- [Instructor] For the coding for this project, I provided a starter file, so go ahead, please, and open the starter file for Joystick and Stepper Motor for this section, and I'll walk through the code with you. So in line one, we're including the library. So in line number three we have the Stepper function, wherein the Stepper function we have the number of steps per revolution, which is 32 for our stepper motor. And then number two, four, three, five are the digital pins that we're connecting from the motor driver. Remember, the sequence is we're going with one, three, two, four. In line five, I initialize an xPin where we connect the input from the x-axis from the Joystick into A0. In line six, I have a variable that we store the values that we get from the analog input into a variable named xValue. For the y-axis, I initialize a variable named yPin where we connect the input that we have from the y-axis that's coming from analog input one. And then for the z-axis, it's a digital…

Contents