Arduino Lesson 13. DC Motors. Created by Simon Monk



Similar documents
Arduino Lesson 14. Servo Motors

Arduino Lesson 9. Sensing Light

Arduino Lesson 16. Stepper Motors

Arduino Lesson 5. The Serial Monitor

Arduino Lesson 0. Getting Started

Arduino Lesson 4. Eight LEDs and a Shift Register

Arduino Lesson 1. Blink

Basic DC Motor Circuits. Living with the Lab Gerald Recktenwald Portland State University

Basic DC Motor Circuits

Arduino Lesson 17. Sending Movement Detector

Your Multimeter. The Arduino Uno 10/1/2012. Using Your Arduino, Breadboard and Multimeter. EAS 199A Fall Work in teams of two!

Adafruit's Raspberry Pi Lesson 9. Controlling a DC Motor

Basic Pulse Width Modulation

Eric Mitchell April 2, 2012 Application Note: Control of a 180 Servo Motor with Arduino UNO Development Board

RGB LED Strips. Created by lady ada. Last updated on :00:18 PM EST

Adafruit's Raspberry Pi Lesson 11. DS18B20 Temperature Sensing

Arduino Motor Shield (L298) Manual

Sending an SMS with Temboo

PHYS 2P32 Project: MIDI for Arduino/ 8 Note Keyboard

SSH to BeagleBone Black over USB

Electronics 5: Arduino, PWM, Mosfetts and Motors

Playing sounds and using buttons with Raspberry Pi

Lab 6 Introduction to Serial and Wireless Communication

ECEN 1400, Introduction to Analog and Digital Electronics

Electronic Brick of Current Sensor

cs281: Introduction to Computer Systems Lab08 Interrupt Handling and Stepper Motor Controller

Thermistor. Created by Ladyada. Last updated on :30:46 PM EDT

Adafruit's Raspberry Pi Lesson 5. Using a Console Cable

Character LCDs. Created by Ladyada. Last updated on :45:29 PM EDT

Adafruit's Raspberry Pi Lesson 5. Using a Console Cable

Set up and Blink - Simulink with Arduino

Adafruit MCP9808 Precision I2C Temperature Sensor Guide

Selecting and Implementing H-Bridges in DC Motor Control. Daniel Phan A

How to Make a Pogo Pin Test Jig. Created by Tyler Cooper

IR Communication a learn.sparkfun.com tutorial

The self-starting solar-powered Stirling engine

revolution Contents: Introduction Power 28-pin Project Board with input/output cables

Adafruit's Raspberry Pi Lesson 5. Using a Console Cable. Created by Simon Monk

Table 1 Comparison of DC, Uni-Polar and Bi-polar Stepper Motors

ARDUINO SEVERINO SERIAL SINGLE SIDED VERSION 3 S3v3 (REVISION 2) USER MANUAL

2.2" TFT Display. Created by Ladyada. Last updated on :15:09 PM EDT

Theory and Practice of Tangible User Interfaces. Thursday Week 2: Digital Input and Output. week. Digital Input and Output. RGB LEDs fade with PWM

DS1307 Real Time Clock Breakout Board Kit

Microcontroller Programming Beginning with Arduino. Charlie Mooney

Cornerstone Electronics Technology and Robotics I Week 15 Voltage Comparators Tutorial

Servo Motors (SensorDAQ only) Evaluation copy. Vernier Digital Control Unit (DCU) LabQuest or LabPro power supply

POWER SUPPLY MODEL XP-15. Instruction Manual ELENCO

Data Sheet. Adaptive Design ltd. Arduino Dual L6470 Stepper Motor Shield V th November L6470 Stepper Motor Shield

Arduino Wifi shield And reciever. 5V adapter. Connecting wifi module on shield: Make sure the wifi unit is connected the following way on the shield:

Introduction to Arduino

Adafruit SHT31-D Temperature & Humidity Sensor Breakout

Transistor Characteristics and Single Transistor Amplifier Sept. 8, 1997

CONSTRUCTING A VARIABLE POWER SUPPLY UNIT

Hand Crank Generator (9 May 05) Converting a Portable Cordless Drill to a Hand Crank DC Generator

1 of 5 12/31/ :51 AM

How to program a Zumo Robot with Simulink

DEPARTMENT OF ELECTRONICS ENGINEERING

Tiny Arduino Music Visualizer

1.8" TFT Display Breakout and Shield

The MOSFET Transistor

Surveillance System Using Wireless Sensor Networks

Pololu DRV8835 Dual Motor Driver Shield for Arduino

TRANSISTOR/DIODE TESTER

DC Motor with Shaft Encoder

UIM2901-5A MACH3 breakout board

H-Bridge Motor Control

Using Arduino Microcontrollers to Sense DC Motor Speed and Position

The basic set up for your K2 to run PSK31 By Glenn Maclean WA7SPY

KTA-223 Arduino Compatible Relay Controller

GLOLAB Two Wire Stepper Motor Positioner

Adafruit Proto Shield for Arduino

Green House Monitoring and Controlling Using Android Mobile Application

AirCasting Particle Monitor Bill of Materials

UPS PIco. to be used with. Raspberry Pi B+, A+, B, and A. HAT Compliant. Raspberry Pi is a trademark of the Raspberry Pi Foundation

Current Loop Application Note 1495

Model 201 Wiegand Touchpad Reader Installation Guide

ABB Drives. User s Manual HTL Encoder Interface FEN-31

TSL2561 Luminosity Sensor

Application Examples

Points Position Indicator (PPI1) for Points Motors with Common Ground

Physics 623 Transistor Characteristics and Single Transistor Amplifier Sept. 13, 2006

Adafruit BME280 Humidity + Barometric Pressure + Temperature Sensor Breakout

RGB Wall Washer Using ILD4035

XPort Universal Demo Board User Guide

Battery Power for LED Pixels and Strips. Created by Phillip Burgess

INDEX. Trademarks All name and product s trademarks mentioned below are the property of their respective companies.

Using voltage regulator to convert 5-12V range to 3.3V. Huan Lin

A REST API for Arduino & the CC3000 WiFi Chip

Experiment NO.3 Series and parallel connection

STUDY OF CELLPHONE CHARGERS

MIDECO 64-outputs MIDI note decoder USER MANUAL. Roman Sowa 2012

Three Arduino Challenges to Connect the Logical World with the Physical One. ISTE Philadelphia

Adding a Real Time Clock to Raspberry Pi

WinLIN Setup and Operation:

POINTS POSITION INDICATOR PPI4

LM 358 Op Amp. If you have small signals and need a more useful reading we could amplify it using the op amp, this is commonly used in sensors.

Controlling a Dot Matrix LED Display with a Microcontroller

Current Loop Tuning Procedure. Servo Drive Current Loop Tuning Procedure (intended for Analog input PWM output servo drives) General Procedure AN-015

8 Channel Status Input Panel model SIP-8

Servo Info and Centering

Transcription:

Arduino Lesson 13. DC Motors Created by Simon Monk

Guide Contents Guide Contents Overview Parts Part Qty Breadboard Layout Arduino Code Transistors Other Things to Do 2 3 4 4 4 6 7 9 11 Adafruit Industries http://learn.adafruit.com/adafruit-arduino-lesson-13-dc-motors Page 2 of 11

Overview In this lesson, you will learn how to control a small DC motor using an Arduino and a transistor. You will use an Arduino analog output (PWM) to control the speed of the motor by sending a number between 0 and 255 from the Serial Monitor. Adafruit Industries http://learn.adafruit.com/adafruit-arduino-lesson-13-dc-motors Page 3 of 11

Parts To build the project described in this lesson, you will need the following parts. Part Qty Small 6V DC Motor 1 PN2222 Transistor 1 1N4001 diode 1 270 Ω Resistor (red, purple, brown stripes) 1 Half-size Breadboard 1 Adafruit Industries http://learn.adafruit.com/adafruit-arduino-lesson-13-dc-motors Page 4 of 11

Arduino Uno R3 1 Jumper wire pack 1 Adafruit Industries http://learn.adafruit.com/adafruit-arduino-lesson-13-dc-motors Page 5 of 11

Breadboard Layout When you put together the breadboard, there are two things to look out for. Firstly, make sure that the transistor is the right way around. The flat side of the transistor should be on the right-hand side of the breadboard. Secondly the striped end of the diode should be towards the +5V power line - see the image below! The motor that comes with Adafruit Arduino kits does not draw more than 250mA but if you have a different motor, it could easily draw 1000mA, more than a USB port can handle! If you aren't sure of a motor's current draw, power the Arduino from a wall adapter, not just USB The motor can be connected either way around. Adafruit Industries http://learn.adafruit.com/adafruit-arduino-lesson-13-dc-motors Page 6 of 11

Arduino Code Load up the following sketch onto your Arduino. /* Adafruit Arduino - Lesson 13. DC Motor */ int motorpin = 3; void setup() { pinmode(motorpin, OUTPUT); Serial.begin(9600); while (! Serial); Serial.println("Speed 0 to 255"); } void loop() { if (Serial.available()) { int speed = Serial.parseInt(); if (speed >= 0 && speed <= 255) { analogwrite(motorpin, speed); } } } The transistor acts like a switch, controlling the power to the motor, Arduino pin 3 is used to turn the transistor on and off and is given the name 'motorpin' in the sketch. When the sketch starts, it prompts you, to remind you that to control the speed of the motor you need to enter a value between 0 and 255 in the Serial Monitor. Adafruit Industries http://learn.adafruit.com/adafruit-arduino-lesson-13-dc-motors Page 7 of 11

In the 'loop' function, the command 'Serial.parseInt' is used to read the number entered as text in the Serial Monitor and convert it into an 'int'. You could type any number here, so the 'if' statement on the next line only does an analog write with this number if the number is between 0 and 255. Adafruit Industries http://learn.adafruit.com/adafruit-arduino-lesson-13-dc-motors Page 8 of 11

Transistors The small DC motor, is likely to use more power than an Arduino digital output can handle directly. If we tried to connect the motor straight to an Arduino pin, there is a good chance that it could damage the Arduino. A small transistor like the PN2222 can be used as a switch that uses just a little current from the Arduino digital output to control the much bigger current of the motor. The transistor has three leads. Most of the electricity flows from the Collector to the Emitter, but this will only happen if a small amount is flowing into the Base connection. This small current is supplied by the Arduino digital output. The diagram below is called a schematic diagram. Like a breadboard layout, it is a way of showing how the parts of an electronic project are connected together. Adafruit Industries http://learn.adafruit.com/adafruit-arduino-lesson-13-dc-motors Page 9 of 11

The pin D3 of the Arduino is connected to the resistor. Just like when using an LED, this limits the current flowing into the transistor through the base. There is a diode connected across the connections of the motor. Diodes only allow electricity to flow in one direction (the direction of their arrow). When you turn the power off to a motor, you get a negative spike of voltage, that can damage your Arduino or the transistor. The diode protects against this, by shorting out any such reverse current from the motor. Adafruit Industries http://learn.adafruit.com/adafruit-arduino-lesson-13-dc-motors Page 10 of 11

Other Things to Do Try reversing the connections to the motor. What happens? Try entering different values (starting at 0) into the Serial Monitor and notice at what value the motor starts to actually turn. You will find that the motor starts to 'sing' as you increase the analog output. Try pinching the drive shaft between your fingers. Don't hold it like that for too long, or you may cook the transistor, but you should find that it is fairly easy to stop the motor. It is spinning fast, but it does not have much torque. About the Author Simon Monk is author of a number of books relating to Open Source Hardware. The following books written by Simon are available from Adafruit: Programming Arduino (http://adafru.it/1019), 30 Arduino Projects for the Evil Genius (http://adafru.it/868) and Programming the Raspberry Pi (http://adafru.it/am5). Adafruit Industries Last Updated: 2013-04-25 12:02:50 PM EDT Page 11 of 11