Download presentation
Presentation is loading. Please wait.
Published byBarnard Wells Modified over 8 years ago
1
Arduino DC Motor Motion Control Instructor: Dr Matthew Khin Yi Kyaw
2
DC Motors It runs on DC voltage It has two power connections(one terminal is positive and the other is negative) The current for running motor is……. Arduino output pin can provide 40mA current So, it needs motor driver.
3
H- Bridge
4
L239DIC 16- pin two-channel motor control IC. Each channel has a separate enable pin, 2 input pins, 2 ground pins, and 2 output pins.
5
Simple DC Motor Motion Control Circuit Diagram
6
Pin Connection of Arduino to Peripheral (motor and switch) Arduino pin 02: pin 12: pin 05: pin 04: Peripheral switch Positive terminal of motor (pin 7) Negative terminal of motor (pin 2) Enable pin for the IC
7
software const int switchPin=2; const int motor1Pin=12; const int motor2Pin=5; const int enablePin=4; void setup(){ pinMode(switchPin,INPUT); pinMode(motor1Pin,OUTPUT); pinMode(motor2Pin,OUTPUT); pinMode(enablePin,OUTPUT); digitalWrite(enablePin,HIGH); } void loop(){ if(digitalRead(switchPin)==HIGH){ digitalWrite(motor1Pin,LOW); digitalWrite(motor2Pin,HIGH); } else { digitalWrite(motor1Pin,HIGH); digitalWrite(motor2Pin,LOW); }
8
Speed Control Using PWM Pin Connection of Arduino to Peripheral (motor and switch) Arduino pin 02: pin 03: pin 05: pin 09: Pin 13: switch Positive terminal of motor (pin 7) Negative terminal of motor (pin 2) Enable pin for the IC Peripheral L.E.D
9
Software 1 Do the pin assignments in setup function 2 Turn the LED on only when the push button is pressed Write PWM code using analogWrite( )
10
Homework You have to complete the following assignments as your homework. 1. Use an input character from the serial port to turn-on the DC motors 2.Implement the given circuit as shown in Figure. 3. Write your own code to control two DC-motors for following scenarios: Both motors are moving in same direction Motors are moving in opposite directions Motor 1 is moving, but motor 2 isn’t moving Motor2 is moving, but motor 1 is moving at half of the speed of motor 2
11
Circuit Diagram of HW2
12
References. http://arduino.cc.. http://arduino.cc/en/Main/ArduinoBoardUno.. http://arduino.cc/en/Guide/Introduction.. www.atmel.com/Images/doc8161.pdf.. \Arduino Programming Notebook" by - by Brian W. Evans.. Beginning Android ADK with Arduino by Mario Bohmer. http://arduino.cc/en/Tutorial/Button. http://arduino.cc/en/Tutorial/Blink. http://arduino.cc/en/uploads/Main/arduino_Uno_Rev3-02-TH.zip.. http://arduino.cc/en/uploads/Main/Arduino_Uno_Rev3-schematic.pdf.. http://arduino.cc/en/Main/ArduinoBoardUno.http://arduino.cc/en/Main/ArduinoBoardUno. http://www.aishack.in/2010/07/the-three-motors-youll-ever-use-in- robotics/. http://arduino.cc/en/Tutorial/SoftwareSerialExample
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.