<?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_11--Microduino_Infrared_Controls_Servo_Angle</id>
		<title>Lesson 11--Microduino Infrared Controls Servo Angle - 版本历史</title>
		<link rel="self" type="application/atom+xml" href="http:///https//wiki.microduino.cn/index.php?action=history&amp;feed=atom&amp;title=Lesson_11--Microduino_Infrared_Controls_Servo_Angle"/>
		<link rel="alternate" type="text/html" href="https//wiki.microduino.cn/index.php?title=Lesson_11--Microduino_Infrared_Controls_Servo_Angle&amp;action=history"/>
		<updated>2026-04-21T09:48:38Z</updated>
		<subtitle>本wiki的该页面的版本历史</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>https//wiki.microduino.cn/index.php?title=Lesson_11--Microduino_Infrared_Controls_Servo_Angle&amp;diff=1663&amp;oldid=prev</id>
		<title>Pkj：/* Program */</title>
		<link rel="alternate" type="text/html" href="https//wiki.microduino.cn/index.php?title=Lesson_11--Microduino_Infrared_Controls_Servo_Angle&amp;diff=1663&amp;oldid=prev"/>
				<updated>2014-03-29T07:52:31Z</updated>
		
		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Program&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;zh-CN&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;←上一版本&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;2014年3月29日 (六) 07:52的版本&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l27&quot; &gt;第27行：&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第27行：&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Program==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Program==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Download program:&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;https://github.com/Microduino/Microduino_Tutorials/tree/master/Microduino_Advanced/MicroduinoIRControlServeAngle&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Pkj</name></author>	</entry>

	<entry>
		<id>https//wiki.microduino.cn/index.php?title=Lesson_11--Microduino_Infrared_Controls_Servo_Angle&amp;diff=1367&amp;oldid=prev</id>
		<title>Pkj：Created page with &quot;{{Language | 第十一课--Microduino 红外控制舵机角度}} {| style=&quot;width: 800px;&quot; |- | ==Objective== This lesson will teach you control the servo by infrared.  ==Equip...&quot;</title>
		<link rel="alternate" type="text/html" href="https//wiki.microduino.cn/index.php?title=Lesson_11--Microduino_Infrared_Controls_Servo_Angle&amp;diff=1367&amp;oldid=prev"/>
				<updated>2014-03-09T12:13:37Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{Language | 第十一课--Microduino 红外控制舵机角度}} {| style=&amp;quot;width: 800px;&amp;quot; |- | ==Objective== This lesson will teach you control the servo by infrared.  ==Equip...&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 lesson will teach you control the servo by infrared.&lt;br /&gt;
&lt;br /&gt;
==Equipment==&lt;br /&gt;
*'''[[Microduino-Core]]'''&lt;br /&gt;
*'''[[Microduino-FT232R]]'''&lt;br /&gt;
*Other equipments:&lt;br /&gt;
**Breadboard Jumper            one box   &lt;br /&gt;
**Breadboard  	               one piece  &lt;br /&gt;
**USB Data cable               one&lt;br /&gt;
**The infrared receiver        one&lt;br /&gt;
**Remote control               one&lt;br /&gt;
**Servo                        one            &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Servo'''&lt;br /&gt;
[[File:第十一课-舵机.jpg|600px|center|thumb]]&lt;br /&gt;
Servo is a set of automatic control system which consists of DC motor, gear set, sensor and control circuit. By sending a signal, the output shaft will rotate specified angle. Generally servo has a maximum rotation angle (such as 180 degrees). The mainly difference between a common DC motor is taht DC motor is circular rotation, servo only can rotate within a certain Angle, can't rotate as circle (digital servo can switch in the servo model and motor model, doesn't have this problem). Common DC motor can't return the rotation angle information, and servo can be. Usage is different also, common DC motor is made power with the whole circle turn, servo is used to control an objuect to rotate a certain angle (such as robot joints).&lt;br /&gt;
&lt;br /&gt;
==Schematic==&lt;br /&gt;
[[File:第十一课-Microduino红外控制舵机角度原理图.jpg|600px|center|thumb]]&lt;br /&gt;
In schematic, the black line is the ground wire and need connect to GNU, red line is the power line to 5V voltage, the blue line is the infrared receiver signal line, the yellow line is the servo signal line.&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;
#include &amp;lt;IRremote.h&amp;gt;&lt;br /&gt;
#include &amp;lt;Servo.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int action;&lt;br /&gt;
int deg=0;&lt;br /&gt;
int t;&lt;br /&gt;
&lt;br /&gt;
int RECV_PIN = 11;//Defien the infrared receive pin&lt;br /&gt;
IRrecv irrecv(RECV_PIN);&lt;br /&gt;
Servo servo;&lt;br /&gt;
decode_results results;&lt;br /&gt;
&lt;br /&gt;
int deckey(unsigned long t)&lt;br /&gt;
{&lt;br /&gt;
  switch(t){&lt;br /&gt;
    case 0xFD08F7://Button 1 encoding&lt;br /&gt;
    return 1;&lt;br /&gt;
    break;&lt;br /&gt;
    case 0xFD8877://Button 2 encoding&lt;br /&gt;
    return 2;&lt;br /&gt;
    break;&lt;br /&gt;
    case 0xFD48B7://Button 3 encoding&lt;br /&gt;
    return 3;&lt;br /&gt;
    break;&lt;br /&gt;
    case 0xFD28D7://Button 4 encoding&lt;br /&gt;
    return 4;&lt;br /&gt;
    break;&lt;br /&gt;
    case 0xFDA857://Button 5 encoding&lt;br /&gt;
    return 5;&lt;br /&gt;
    break;&lt;br /&gt;
    case 0xFD6897://Button 6 encoding&lt;br /&gt;
    return 6;&lt;br /&gt;
    break;&lt;br /&gt;
    case 0xFD18E7://Button 7 encoding&lt;br /&gt;
    return 7;&lt;br /&gt;
    break;&lt;br /&gt;
    case 0xFD9867://Button 8 encoding&lt;br /&gt;
    return 8;&lt;br /&gt;
    break;&lt;br /&gt;
    case 0xFD58A7://Button 9 encoding&lt;br /&gt;
    return 9;&lt;br /&gt;
    break;&lt;br /&gt;
    default:&lt;br /&gt;
    return 0;&lt;br /&gt;
    break;&lt;br /&gt;
  }&lt;br /&gt;
}   &lt;br /&gt;
&lt;br /&gt;
void setup()&lt;br /&gt;
{&lt;br /&gt;
  Serial.begin(9600);&lt;br /&gt;
  irrecv.enableIRIn(); // Initialize the infrared receiver&lt;br /&gt;
  servo.attach(9);&lt;br /&gt;
  servo.write(0);&lt;br /&gt;
  t=0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void loop() {&lt;br /&gt;
&lt;br /&gt;
  deg=servo.read();&lt;br /&gt;
  if (irrecv.decode(&amp;amp;results))&lt;br /&gt;
  {&lt;br /&gt;
    action=deckey(results.value);&lt;br /&gt;
    Serial.println(results.value, HEX);//In hexadecimal output to receive code with a new line&lt;br /&gt;
    Serial.println(action);&lt;br /&gt;
    Serial.println();//In order to easy observe the output increase a blank line&lt;br /&gt;
&lt;br /&gt;
    switch(action)&lt;br /&gt;
    {&lt;br /&gt;
      case 1:&lt;br /&gt;
      servo.write(0);&lt;br /&gt;
      break;&lt;br /&gt;
      case 2:&lt;br /&gt;
      servo.write(20);&lt;br /&gt;
      break;&lt;br /&gt;
      case 3:&lt;br /&gt;
      servo.write(40);&lt;br /&gt;
      break;&lt;br /&gt;
      case 4:&lt;br /&gt;
      servo.write(60);&lt;br /&gt;
      break;&lt;br /&gt;
      case 5:&lt;br /&gt;
      servo.write(80);&lt;br /&gt;
      break;&lt;br /&gt;
      case 6:&lt;br /&gt;
      servo.write(100);&lt;br /&gt;
      break;&lt;br /&gt;
      case 7:&lt;br /&gt;
      servo.write(120);&lt;br /&gt;
      break;&lt;br /&gt;
      case 8:&lt;br /&gt;
      servo.write(140);&lt;br /&gt;
      break;&lt;br /&gt;
      case 9:&lt;br /&gt;
      servo.write(160);&lt;br /&gt;
      break;&lt;br /&gt;
    }&lt;br /&gt;
    delay(10);&lt;br /&gt;
    irrecv.resume();&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：Download IRremote library&lt;br /&gt;
[http://www.geek-workshop.com/forum.php?mod=attachment&amp;amp;aid=ODk2N3wyYmQ0YTJlYnwxMzkxODcwMDU5fDI4MTYzfDI0MzM=]&lt;br /&gt;
&lt;br /&gt;
Step 2：Uncompress the library to libraries folder of Arduino IDE&lt;br /&gt;
&lt;br /&gt;
Step 3: Set up the circuit；&lt;br /&gt;
[[File:第十一课-Microduino红外控制舵机角度图1.jpg|600px|center|thumb]]&lt;br /&gt;
[[File:第十一课-Microduino红外控制舵机角度图2.jpg|600px|center|thumb]]&lt;br /&gt;
&lt;br /&gt;
Step 4: open the serial monitor, the remote control  towards to the infrared receiver button, infrared codes will be shown.&lt;br /&gt;
[[File:第十一课-串口显示红外接收编码并转换为按键值.jpg|600px|center|thumb]]&lt;br /&gt;
&lt;br /&gt;
==Result==&lt;br /&gt;
Press the button 1,2,3,4..., servo will rotate.&lt;br /&gt;
&lt;br /&gt;
==Video==&lt;br /&gt;
http://v.youku.com/v_show/id_XNjc1NjQ4Mzcy.html&lt;/div&gt;</summary>
		<author><name>Pkj</name></author>	</entry>

	</feed>