<?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=Control_DC_motor</id>
		<title>Control DC motor - 版本历史</title>
		<link rel="self" type="application/atom+xml" href="http:///https//wiki.microduino.cn/index.php?action=history&amp;feed=atom&amp;title=Control_DC_motor"/>
		<link rel="alternate" type="text/html" href="https//wiki.microduino.cn/index.php?title=Control_DC_motor&amp;action=history"/>
		<updated>2026-06-07T03:20:09Z</updated>
		<subtitle>本wiki的该页面的版本历史</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>https//wiki.microduino.cn/index.php?title=Control_DC_motor&amp;diff=2863&amp;oldid=prev</id>
		<title>Pkj：Created page with &quot;{| style=&quot;width: 800px;&quot; |- | ==Objective==  The course will show you how to use “Processing” to control the speed of the DC motor.   ==Equipment== *'''Microduino-Core...&quot;</title>
		<link rel="alternate" type="text/html" href="https//wiki.microduino.cn/index.php?title=Control_DC_motor&amp;diff=2863&amp;oldid=prev"/>
				<updated>2014-06-03T10:19:10Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;{| style=&amp;quot;width: 800px;&amp;quot; |- | ==Objective==  The course will show you how to use “Processing” to control the speed of the DC motor.   ==Equipment== *&amp;#039;&amp;#039;&amp;#039;&lt;a href=&quot;/index.php/Microduino-Core&quot; title=&quot;Microduino-Core&quot;&gt;Microduino-Core&lt;/a&gt;...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{| style=&amp;quot;width: 800px;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
==Objective==&lt;br /&gt;
&lt;br /&gt;
The course will show you how to use “Processing” to control the speed of the DC motor. &lt;br /&gt;
&lt;br /&gt;
==Equipment==&lt;br /&gt;
*'''[[Microduino-Core]]'''&lt;br /&gt;
*'''[[Microduino-FT232R]]'''&lt;br /&gt;
&lt;br /&gt;
*Other Hardware Equipment &lt;br /&gt;
**A USB cable &lt;br /&gt;
**A box of jumpers &lt;br /&gt;
**A breadboard&lt;br /&gt;
**A DC motor &lt;br /&gt;
**A potentiometer  &lt;br /&gt;
**A resistor of 2.2K Ω &lt;br /&gt;
**A diode  &lt;br /&gt;
**A transistor NPN&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Schematic==&lt;br /&gt;
&lt;br /&gt;
[[File:processingDCMotorSchematics.jpg|600px|center|thumb]]&lt;br /&gt;
&lt;br /&gt;
==Program==&lt;br /&gt;
&lt;br /&gt;
Refer to MicroduinoDCMotorControl&lt;br /&gt;
&lt;br /&gt;
ProcessingDCMotorControl&lt;br /&gt;
&lt;br /&gt;
==Debugging==&lt;br /&gt;
&lt;br /&gt;
Step 1：Build hardware environment in accord with the schematic, just like this:  &lt;br /&gt;
[[File:processingDCMotorConnectionDiagram.jpg|600px|center|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Step 2：Here the code we need：&lt;br /&gt;
&lt;br /&gt;
The code of the two ends (Processing and Microduino)  &lt;br /&gt;
&lt;br /&gt;
Microduino:&lt;br /&gt;
&lt;br /&gt;
//Send output value to the motor after getting the serial data &lt;br /&gt;
&lt;br /&gt;
  if(Serial.available())//if serial is available&lt;br /&gt;
  {&lt;br /&gt;
    leitura=Serial.read();//read serial data&lt;br /&gt;
    Serial.println(leitura);&lt;br /&gt;
    vel=map(leitura,0,255,0,1023);//map&lt;br /&gt;
    if(leitura&amp;gt;0)//run motor by leitura&lt;br /&gt;
    {&lt;br /&gt;
      analogWrite(motorPin,vel);&lt;br /&gt;
      delay(1);&lt;br /&gt;
    }&lt;br /&gt;
    else//stop motor&lt;br /&gt;
    {&lt;br /&gt;
      analogWrite(motorPin,LOW);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Processing:&lt;br /&gt;
&lt;br /&gt;
//List all the serial ports and get data of the first serial port &lt;br /&gt;
  // List all the available serial ports in the output pane.&lt;br /&gt;
  // You will need to choose the port that the Wiring board is&lt;br /&gt;
  // connected to from this list. The first port in the list is&lt;br /&gt;
  // port #0 and the third port in the list is port #2.&lt;br /&gt;
  println(Serial.list());&lt;br /&gt;
  // Open the port that the Wiring board is connected to (in this case #0)&lt;br /&gt;
  // Make sure to open the port at the same speed Wiring is using (9600bps)&lt;br /&gt;
  port = new Serial(this, Serial.list()[0], 9600);&lt;br /&gt;
&lt;br /&gt;
//Draw and update&lt;br /&gt;
  void draw() &lt;br /&gt;
  {&lt;br /&gt;
    background(0);&lt;br /&gt;
    update(mouseX/10); &lt;br /&gt;
    println(mouseX);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
//Transmit the x-coordinate value of the mouse through the serial port and draw the current value on Processing &lt;br /&gt;
  void update(int x) &lt;br /&gt;
  {&lt;br /&gt;
    port.write(x);&lt;br /&gt;
    stroke(255);  &lt;br /&gt;
    line(mouseX, 0, mouseX, 160);   &lt;br /&gt;
    text (mouseX, mouseX, 180);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Step 3：Download the code and compile successfully. . &lt;br /&gt;
&lt;br /&gt;
Step 4：Move your mouse around in “Processing” after the system goes well to see speed change of the motor. &lt;br /&gt;
&lt;br /&gt;
==Result==&lt;br /&gt;
&lt;br /&gt;
A simple speed indicator will be displayed on the screen. The speed of the motor will change along with the change of your mouse on the x-coordinate. &lt;br /&gt;
[[File:processingDCMotorResult.jpg|600px|center|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Video==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Pkj</name></author>	</entry>

	</feed>