Arduino Tutorial: Control Stepper motor Using Potentiometer

in hive-148441 •  29 days ago 


Hello, Hive community! This tutorial is an open-source Arduino project that teaches how to control Stepper motor using potentiometer I am going to use LCD 16X2 with II2 backpacks to display the meter speed of the stepper motor.


Requirements needed for this tutorial

  • Stepper motor+ motor driver
  • LCD 16X2
  • Breadboard
  • Jumper wires
  • Potentiometer
  • Type B USB cable
  • Arduino Microcontroller board
  • PC/laptop

Build the circuit

The Arduino UNO R3

has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz quartz crystal, a USB connection, a power jack, an ICSP header and a reset button. 32k Flash Memory, 

source

Codes and programs can be uploaded on to it from the Arduino computer program. which makes it a very easy way to get started working with embedded electronics. The name R3 is the third, and latest version of Arduino Uno Board



The 16x 2 LCD with I2C module you will be able to connect the LCD with Arduino board with only two Data cables! The II2c module has a built-in potentiometer backpack for contrast adjustment. The 16x2 display is the setup LCD number of columns and rows ( 16 columns, 2 rows Display ). has 4 build-in backpack pins (1) VCC it refers to the power signal of the LCD typically connected to 5volts, (2)GND or sometimes zero voltage, It is also the common connection of the LCD must connect to in one way or another path in order to complete the circuit. (3) SDA and (4) SCL is the II2c serial bus pin it is used to synchronize all data transfers over the II2c bus from the 16 pin of the normal LCD, Both SCL and SDA are connected to analog pin outputs of the Arduino because II2c lines are open-drain drivers, means is that the chip can drive its output low.

Connection of LCD to Arduino

  • GND- GND

  • VCC - 5V

  • SCL - A4

  • SDA - A5


image

The stepper motor converts electrical power to mechanical like the servo and Dc dynamo motors as its belonging. A step motor has two primary parts; the rotor, the moving piece, and the stator, the stationary piece. The stator contains coils of wire called windings, the pulse generator part can instruct the stepper for acceleration, run at a speed, decelerate or stop, then the pulse generator must be presented, or else the motor will not move.


Connection of stepper Driver to Arduino

the stepper driver used ULN2003A to amplify the control signal from the Arduino, it converts pulse to angle displacement. So if you give the stepper driver a certain pulse signal, it will drive step motor to a certain angle. you can control the angle the stepper moved by the number of the pulse. And you also can control the speed of the stepper rotate by the frequency of the pulse using a potentiometer which shows in this tutorial.

  • INput 1 - Digital pin 9 of the Arduino
  • IN 2 - pin 10
  • IN 3 - pin 11
  • IN 4 - pin 12

  • Connection of potentiometer to Arduino

A potentiometer is a device whose resistance or current flow can be manually adjusted by rotating it, Increasing or decreasing the value of resistance controls the amount of current flowing in a circuit. we will this as a knob to control the value of the rotating stepper motor. the analog A0 to the middle pin of the pot it sends the data signal to Arduino and the GND and VCC as the power source.


  • Download the Software and Libraries

If you’re ready to get started, click on the link below then select the version with your operating system.
Download the Arduino Desktop IDE: https://www.arduino.cc/en/Main/Software
When the download is finished, un-zip it and open up the Arduino folder to confirm that click yes, there are some files and sub-folders inside. The file structure is important so don’t be moving any files around unless you really know what you’re doing.

Download the liquid crystal LCD library: https://github.com/fdebrabander/Arduino-LiquidCrystal-I2C-library This library is a modified version of the H. Mario LiquidCrystal_I2C V.2.0 lib.

  • Include libraries to Arduino IDE

Once installed the Arduino desktop IDE. open the software then locate the SKETCH tab at the top of the software, navigate ADD ZIP LIBRARY >> then look for the downloaded libraries in the download folder. SELECT the zip file then wait for the process. include all the libraries fo liquid-crystal display.


  • Step 5: Programming

We are using the GitHub repository; https://github.com/cheon7886/DreamCircuit/blob/master/stepper_speedControl_with_LCD.ino to control the stepper

Download the sketch code here: http://www.mediafire.com/file/3zxhwtww18kv647/steppermotor.txt/file

note: the code from GitHub uses non-i2c LCD code on the sketch if you're using LCD with i2c backpack use code above.

  • Now, you can see the value of stepping motor rotation on the LCD you can control the speed by rotating the potentiometer


Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!