top of page

Lab 5: Motors

In this lab you will explore motors and building circuits using DC and stepper motors driven with an H-Bridge. 

Part 1: DC Motor Control

In this part of the lab, you’ll learn how to drive a DC motor. To control a DC motor to turn in both directions, you need to be able to reverse the direction of the current supply to the motor. The easiest way to do this is using an H-bridge circuit.

IMG_2154.HEIC

Schematic Drawing of the Circuit

Final Circuit (but I ended up changing the switch to a button)

IMG_2145_edited.jpg

Following the schematic itself was pretty simple, but it started to get difficult when it came to understanding how the h-bridge works. The code outline was very helpful and I was able to figure out the code pretty quickly. My arduino was starting to act up so I was having trouble uploading to my board. 

This video shows the motor running. This part was obviously pretty simple because I just followed the circuit diagram, and the motor ran as soon as it had power connected to it. 

This is where I wrote the code. When the button isn't being pushed, the motor runs the way that it's set up in the setup function. When the button is pushed, the motor spins in the opposite direction at a slower speed. The speed difference is hard to tell, so hopefully it's more obvious with the piece of paper I stuck on the end. 

I had trouble trying to change the values with analog write in order to change the speed, and I also had trouble changing the direction. I thought my switch was broken so I used a button, but I eventually figured out that my code wasn't making sense. 

Part 2: Stepper Motor Control

Stepper motors have multiple coils in them, so that they can be moved in small increments or steps. Stepper motors are typically either unipolar or bipolar, meaning that they have either one main power connection or two. This lab shows you how to set up a unipolar stepper motor using an H-Bridge. You can also use the same control circuit with a bipolar motor.

IMG_2155.HEIC

Schematic Drawing of the Circuit

This circuit was a little more difficult to build, only because I decided to use jumper wires, which really got in the way. After figuring out the h-bridge from the previous motor setup, this one was very intuitive to me.

IMG_2150.HEIC
IMG_2149.HEIC
IMG_2151.HEIC
IMG_2153.HEIC

My stepper motor wires were all stranded, and since I didn't have a soldering iron, I had to do something a little different. I decided to use electrical tape, even though it's not a fool proof way to connect wires. By some miracle it worked and I had no issues and didn't have to troubleshoot at all. The sample code given in the writeup was super easy to follow and understand, and I found my revolution value and changed it. The wiring for this motor is a mess but the function of it as well as the code is so simple.

This video shows the stepper motor making a full revolution, then a delay, and so on. My code below is primarily from https://www.arduino.cc/en/Tutorial/StepperOneRevolution. This sample code was super easy to understand. 

© 2023 by Meganne Jimenez. Proudly created with Wix.com

bottom of page