<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-CN">
		<id>http:///https//wiki.microduino.cn/index.php?action=history&amp;feed=atom&amp;title=Lesson_41--Microduino_Dc_Motor_Rotation_Control</id>
		<title>Lesson 41--Microduino Dc Motor Rotation Control - 版本历史</title>
		<link rel="self" type="application/atom+xml" href="http:///https//wiki.microduino.cn/index.php?action=history&amp;feed=atom&amp;title=Lesson_41--Microduino_Dc_Motor_Rotation_Control"/>
		<link rel="alternate" type="text/html" href="https//wiki.microduino.cn/index.php?title=Lesson_41--Microduino_Dc_Motor_Rotation_Control&amp;action=history"/>
		<updated>2026-04-30T10:42:53Z</updated>
		<subtitle>本wiki的该页面的版本历史</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>https//wiki.microduino.cn/index.php?title=Lesson_41--Microduino_Dc_Motor_Rotation_Control&amp;diff=1509&amp;oldid=prev</id>
		<title>Pkj：Created page with &quot;{{Language|第四十一课--Microduino 直流电机正反转}} {| style=&quot;width: 800px;&quot; |- | ==Objective== This tutorial will teach you use a simple way to achieve the forward...&quot;</title>
		<link rel="alternate" type="text/html" href="https//wiki.microduino.cn/index.php?title=Lesson_41--Microduino_Dc_Motor_Rotation_Control&amp;diff=1509&amp;oldid=prev"/>
				<updated>2014-03-21T07:58:28Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{Language|第四十一课--Microduino 直流电机正反转}} {| style=&amp;quot;width: 800px;&amp;quot; |- | ==Objective== This tutorial will teach you use a simple way to achieve the forward...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Language|第四十一课--Microduino 直流电机正反转}}&lt;br /&gt;
{| style=&amp;quot;width: 800px;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
==Objective==&lt;br /&gt;
This tutorial will teach you use a simple way to achieve the forward and backward rotation of a dc motor.&lt;br /&gt;
&lt;br /&gt;
==Equipment==&lt;br /&gt;
*'''[[Microduino-Core]]'''&lt;br /&gt;
*'''[[Microduino-FT232R]]'''&lt;br /&gt;
*Other equipment&lt;br /&gt;
**Breadboard Jumper            one box   &lt;br /&gt;
**Breadboard  	               one piece  &lt;br /&gt;
**DC motor                     one &lt;br /&gt;
**USB cable                    one&lt;br /&gt;
&lt;br /&gt;
==Schematic==&lt;br /&gt;
[[File:第四十一课-Microduino直流电机正反转原理图.jpg|600px|center|thumb]]&lt;br /&gt;
&lt;br /&gt;
Note：This isn't one of the most safe method to control the motor, because each I/O pin only can carry 40mA current. If as a practical application, recommend using H-Bridge motor driver board.&lt;br /&gt;
&lt;br /&gt;
==Program==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int motorPin1 =  5;    // Motor's one end connects to digital pin 5&lt;br /&gt;
int motorPin2 =  6;    // The other end connects to digital pin 6&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
void setup()   {                &lt;br /&gt;
  //Initialization, set these two pins as output&lt;br /&gt;
  pinMode(motorPin1, OUTPUT); &lt;br /&gt;
  pinMode(motorPin2, OUTPUT);  &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
void loop()                     &lt;br /&gt;
{&lt;br /&gt;
  rotateLeft(150, 500);//Left rotate, speed=150, lasts 500ms&lt;br /&gt;
  rotateRight(50, 1000);//Right rotate, speed=50, lasts 1000ms&lt;br /&gt;
  rotateRight(150, 1000);//Right rotate, speed=150, lasts 1000ms&lt;br /&gt;
  rotateRight(200, 1000);//Right rotate, speed=200, lasts 1000ms&lt;br /&gt;
  rotateLeft(255, 500);//Left rotate, speed=255, lasts 500ms&lt;br /&gt;
  rotateRight(10, 1500);//Right rotate, speed=10, lasts 1500ms&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//Turn left&lt;br /&gt;
void rotateLeft(int speedOfRotate, int length){&lt;br /&gt;
  analogWrite(motorPin1, speedOfRotate); //Use pwm to set the current&lt;br /&gt;
  digitalWrite(motorPin2, LOW);    // Set motorPin2 to LOW&lt;br /&gt;
  delay(length); //waits&lt;br /&gt;
  digitalWrite(motorPin1, LOW);    // Set motorPin1 to LOW&lt;br /&gt;
}&lt;br /&gt;
//Trun right&lt;br /&gt;
void rotateRight(int speedOfRotate, int length){&lt;br /&gt;
  analogWrite(motorPin2, speedOfRotate); //Use pwm to set the current&lt;br /&gt;
  digitalWrite(motorPin1, LOW);    // Set motorPin1 to LOW&lt;br /&gt;
  delay(length); //waits&lt;br /&gt;
  digitalWrite(motorPin2, LOW);    // Set motorPin2 to LOW&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//Full speed turn left&lt;br /&gt;
void rotateLeftFull(int length){&lt;br /&gt;
  digitalWrite(motorPin1, HIGH); //Set max current&lt;br /&gt;
  digitalWrite(motorPin2, LOW);    // Set motorPin2 to LOW&lt;br /&gt;
  delay(length); //waits&lt;br /&gt;
  digitalWrite(motorPin1, LOW);    // Set motorPin1 to LOW&lt;br /&gt;
}&lt;br /&gt;
//Full speed turn right&lt;br /&gt;
void rotateRightFull(int length){&lt;br /&gt;
  digitalWrite(motorPin2, HIGH); //Set max current&lt;br /&gt;
  digitalWrite(motorPin1, LOW);    // Set motorPin1 to LOW&lt;br /&gt;
  delay(length); //waits&lt;br /&gt;
  digitalWrite(motorPin2, LOW);    // Set motorPin2 to LOW&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Debug==&lt;br /&gt;
Step 1：Copy the code to IDE and compile it&lt;br /&gt;
&lt;br /&gt;
Step 2：Set up circuit, as follows：&lt;br /&gt;
[[File:第四十一课-Microduino直流电机正反转连接图.jpg|600px|center|thumb]]&lt;br /&gt;
&lt;br /&gt;
Step 3：Run program&lt;br /&gt;
&lt;br /&gt;
Step 4：Check the rotation of motor&lt;br /&gt;
&lt;br /&gt;
==Result==&lt;br /&gt;
&lt;br /&gt;
Motor will rotate forward and backward with different speed and in circle.&lt;br /&gt;
&lt;br /&gt;
==Video==&lt;br /&gt;
&lt;br /&gt;
http://v.youku.com/v_show/id_XNjgyNDgzNzM2.html&lt;/div&gt;</summary>
		<author><name>Pkj</name></author>	</entry>

	</feed>