<?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_5--Microduino_Simulates_Computer_Keyboard</id>
		<title>Lesson 5--Microduino Simulates Computer Keyboard - 版本历史</title>
		<link rel="self" type="application/atom+xml" href="http:///https//wiki.microduino.cn/index.php?action=history&amp;feed=atom&amp;title=Lesson_5--Microduino_Simulates_Computer_Keyboard"/>
		<link rel="alternate" type="text/html" href="https//wiki.microduino.cn/index.php?title=Lesson_5--Microduino_Simulates_Computer_Keyboard&amp;action=history"/>
		<updated>2026-06-05T23:19:11Z</updated>
		<subtitle>本wiki的该页面的版本历史</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>https//wiki.microduino.cn/index.php?title=Lesson_5--Microduino_Simulates_Computer_Keyboard&amp;diff=1658&amp;oldid=prev</id>
		<title>Pkj：/* Program */</title>
		<link rel="alternate" type="text/html" href="https//wiki.microduino.cn/index.php?title=Lesson_5--Microduino_Simulates_Computer_Keyboard&amp;diff=1658&amp;oldid=prev"/>
				<updated>2014-03-29T07:46:29Z</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:46的版本&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-l41&quot; &gt;第41行：&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第41行：&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/MicroduinoAnologKeyborad&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_5--Microduino_Simulates_Computer_Keyboard&amp;diff=1557&amp;oldid=prev</id>
		<title>Jasonsheng：Created page with &quot;{{Language|第五课--Microduino 模拟电脑键盘}} {| style=&quot;width: 800px;&quot; |- | ==Objective== This toturial will use the Microduino to simulate a keyboard, you can input t...&quot;</title>
		<link rel="alternate" type="text/html" href="https//wiki.microduino.cn/index.php?title=Lesson_5--Microduino_Simulates_Computer_Keyboard&amp;diff=1557&amp;oldid=prev"/>
				<updated>2014-03-25T05:09:43Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{Language|第五课--Microduino 模拟电脑键盘}} {| style=&amp;quot;width: 800px;&amp;quot; |- | ==Objective== This toturial will use the Microduino to simulate a keyboard, you can input t...&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 toturial will use the Microduino to simulate a keyboard, you can input the &amp;quot;hello world&amp;quot; in notepad.&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;
**68Ω (50~100Ω) registor       two&lt;br /&gt;
**2.2kΩ (1.5~2.2kΩ) registor   one&lt;br /&gt;
**USB cable(one end is USB port, the other end is wire) one&lt;br /&gt;
**3.6v voltage regulator tube (suggest to use 0.25~0.5w)  two&lt;br /&gt;
**USB cable                    one&lt;br /&gt;
&lt;br /&gt;
'''Voltage regulator tube introduction:'''&lt;br /&gt;
[[File:第五课-稳压管.jpg|600px|center|thumb]]&lt;br /&gt;
&lt;br /&gt;
Voltage regulator diode (also called zener diode) is a kind of silicon surface contact type crystal diode which made of silicon, voltage regulator tube for short.&lt;br /&gt;
The diode is a high resistance semiconductor devices until the critical reverse breakdown voltage.&lt;br /&gt;
&lt;br /&gt;
Before voltage regulator tube wase reverse breakdown, in a certain range of current (or within a certain range power consume), terminal voltage is almost a constant and show the stable voltage characteristic, therefore widely used in the stabilized voltage supply and limiting circuit. Voltage regulator diode is devided according to the breakdown voltage, because of this characteristic, voltage regulator tube is mainly used as stabilizer or voltage reference element.&lt;br /&gt;
&lt;br /&gt;
Voltage regulator diode can be used in series together at higher voltage, and then obtain more stable voltage&lt;br /&gt;
&lt;br /&gt;
==Schematic==&lt;br /&gt;
[[File:第五课-Microduino模拟电脑键盘原理图.jpg|600px|center|thumb]]&lt;br /&gt;
'''Schematic introduction：'''&lt;br /&gt;
&lt;br /&gt;
1. Two 68Ω registor play a current-limiting and protection function, prevent accidents in case of damage to the computer's USB port or microcomputer port.&lt;br /&gt;
&lt;br /&gt;
2. 2.2kΩ is the pull up resistors, used to distinguish the state of the bus. If the pull-up resistor connects to the D+ and + 5v, it is a high speed USB device, otherwise connects to D- and +5 v, used as the low speed device. The keyboard transmission rate isn't high in our experiment, so connenct to D- as the low speed device.&lt;br /&gt;
&lt;br /&gt;
3. Connect to D+ and D-'s 3.6 V voltage regulator diode D1 and D2 have the effect of limiting the level on the cable. Because the USB specification specified that the voltage levle range on the D + and D is 3.0 V to 3.6 V, and the output level of AVR microcontroller is Vcc. If the MCU's Vcc is 5 v, in the absence of D1 and D2 will cause voltage level mismatch, which can cause unable to correctly recognize the USB device in many computer. If the user's system Vcc between 3.0 V and 3.6 V, you can omit the two voltage regulator diode. So you also can see the user's system Vcc must be higher than 3v.&lt;br /&gt;
&lt;br /&gt;
4. Due to the low speed AVRUSB need 1.5 MHz clock, and MCU's every 8 instruction can accurately complete a collection of data bits. So AVRUSB's minimum microcontroller clock frequency is 12 MHZ. And you also can use 12 MHz, 12.8 MHz,15 MHz, 16 MHz and 16.5 MHz and 20 MHz clock frequency, and doesn't support others. So if you use the small system to make the simulated keyboard, ATMega8L doesn't work.&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;
    /*&lt;br /&gt;
	Microduino simulate keyboard&lt;br /&gt;
   &lt;br /&gt;
    Function description：Plug in the simulate keyboard, open the notepad, then press the button, will print the &amp;quot;HELLO WORKD&amp;quot; in notepad&lt;br /&gt;
     &lt;br /&gt;
    Connect method：&lt;br /&gt;
    Microduino D2 connects to 68Ω registor, then connects to USB D+&lt;br /&gt;
    Microduino D4 connects to 68Ω registor, then connects to USB D-&lt;br /&gt;
    Microduino D5 connects to 2.2kΩ registor, then connects to USB D-&lt;br /&gt;
    Microduino D2 connects to 3.6v voltage regulator tube and then connects to GND&lt;br /&gt;
    Microduino D4 connects to 3.6v voltage regulator tube and then connects to GND&lt;br /&gt;
    +5v connects to USB VCC&lt;br /&gt;
    GND connects to USB GND&lt;br /&gt;
    Microduino D1 connects to a button and then connects to GND&lt;br /&gt;
     &lt;br /&gt;
    Note：USB color line sequence（Because each manufacturer is different, not necessarily accurate, only for reference）&lt;br /&gt;
    *USB keyboard/mouse：|        *USB interface&lt;br /&gt;
    White&amp;lt;-&amp;gt;VCC          |        Red&amp;lt;-&amp;gt;VCC&lt;br /&gt;
    Orange&amp;lt;-&amp;gt;D-          |        White&amp;lt;-&amp;gt;D-&lt;br /&gt;
    Green&amp;lt;-&amp;gt;D+           |        Green&amp;lt;-&amp;gt;D+&lt;br /&gt;
    Bule&amp;lt;-&amp;gt;GND           |        Black&amp;lt;-&amp;gt;GND     &lt;br /&gt;
    */&lt;br /&gt;
     &lt;br /&gt;
    #include &amp;quot;UsbKeyboard.h&amp;quot;&lt;br /&gt;
    int KEYPIN = 1;                //Button connects to D1 pin, and also can connects to other pin&lt;br /&gt;
    void setup()&lt;br /&gt;
    {&lt;br /&gt;
      TIMSK0 &amp;amp;= !(1 &amp;lt;&amp;lt; TOIE0);        &lt;br /&gt;
      pinMode(KEYPIN, INPUT);&lt;br /&gt;
      digitalWrite(KEYPIN, HIGH);&lt;br /&gt;
    }&lt;br /&gt;
    void loop()&lt;br /&gt;
    {&lt;br /&gt;
      UsbKeyboard.update();&lt;br /&gt;
      if(digitalRead(KEYPIN) == HIGH)&lt;br /&gt;
      {&lt;br /&gt;
        delay(100);&lt;br /&gt;
        if(digitalRead(KEYPIN) == LOW)&lt;br /&gt;
        {&lt;br /&gt;
          UsbKeyboard.sendKeyStroke(KEY_H);&lt;br /&gt;
          UsbKeyboard.sendKeyStroke(KEY_E);&lt;br /&gt;
          UsbKeyboard.sendKeyStroke(KEY_L);&lt;br /&gt;
          UsbKeyboard.sendKeyStroke(KEY_L);&lt;br /&gt;
          UsbKeyboard.sendKeyStroke(KEY_O);&lt;br /&gt;
          UsbKeyboard.sendKeyStroke(KEY_SPACE);&lt;br /&gt;
          UsbKeyboard.sendKeyStroke(KEY_W);&lt;br /&gt;
          UsbKeyboard.sendKeyStroke(KEY_O);&lt;br /&gt;
          UsbKeyboard.sendKeyStroke(KEY_R);&lt;br /&gt;
          UsbKeyboard.sendKeyStroke(KEY_L);&lt;br /&gt;
          UsbKeyboard.sendKeyStroke(KEY_D);&lt;br /&gt;
          UsbKeyboard.sendKeyStroke(KEY_ENTER);&lt;br /&gt;
        }&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;
&lt;br /&gt;
First introduce the library, need uncompress it then copy to libraries folder of arduinoIDE, then restart the arduinoIDE to load this library.&lt;br /&gt;
&lt;br /&gt;
Arduino library：&lt;br /&gt;
&lt;br /&gt;
http://soft1.wmzhe.com/download/Ansifa2012/Arduino/UsbKeyboard.zip&lt;br /&gt;
&lt;br /&gt;
Note：&lt;br /&gt;
&lt;br /&gt;
1、In UsbKeyboard library, you can change the pin defination in file usbconfig.h, the following is a general explaination (The PORTD is AVR MCU's PORTD, you can find the Arduino's corresponding pin from Arduino's schematic)：&lt;br /&gt;
&lt;br /&gt;
 #define USB_CFG_IOPORTNAME D&lt;br /&gt;
&lt;br /&gt;
USB input/output pin, uses AVR MCU's PORTD. If change to B, that will use PORTB&lt;br /&gt;
&lt;br /&gt;
 #define USB_CFG_DMINUS_BIT 4&lt;br /&gt;
&lt;br /&gt;
USB's D- connects to the fourth bit PD4 of PORTD, corresponding to Arduino's D4&lt;br /&gt;
&lt;br /&gt;
 #define USB_CFG_DPLUS_BIT  2&lt;br /&gt;
&lt;br /&gt;
USB's D+ connects to the second bit PD2 of PORTD, correspondign to Arduino's D2&lt;br /&gt;
&lt;br /&gt;
 #define USB_CFG_PULLUP_IOPORTNAME D&lt;br /&gt;
&lt;br /&gt;
USB pull up pin connnecs to AVR MCU's PORTD, If change to B, that will use PORTB&lt;br /&gt;
&lt;br /&gt;
 #define USB_CFG_PULLUP_BIT  5&lt;br /&gt;
&lt;br /&gt;
USB pull up registor connects to the fifth bit PD5 of PORTD, corresponding to Arduino's D5&lt;br /&gt;
&lt;br /&gt;
2. In UsbKeyboard librayr's file UsbKeyboard.h, defines the simulate key value&lt;br /&gt;
&lt;br /&gt;
 #define KEY_A       4&lt;br /&gt;
&lt;br /&gt;
 #define KEY_B       5&lt;br /&gt;
&lt;br /&gt;
 #define KEY_C       6&lt;br /&gt;
&lt;br /&gt;
 #define KEY_D       7&lt;br /&gt;
&lt;br /&gt;
 #define KEY_E       8&lt;br /&gt;
&lt;br /&gt;
This doesn't cover all cases. Actually through the testing, this keyboard can simulate all key value except Power, Sleep and Pause.&lt;br /&gt;
&lt;br /&gt;
For example, direction key right,left, up and down corresponding to number 79,80,81 and 82. &lt;br /&gt;
&lt;br /&gt;
UsbKeyboard.sendKeyStroke(79);&lt;br /&gt;
&lt;br /&gt;
UsbKeyboard.sendKeyStroke(81);&lt;br /&gt;
&lt;br /&gt;
Becuase there are many case, we can't list all of them, you can download the software &amp;quot;KeyboardTest&amp;quot; to test different key value.&lt;br /&gt;
&lt;br /&gt;
Step 1：Copy the code to IDE and compile it&lt;br /&gt;
&lt;br /&gt;
Step 2：Set up circuti, as following：&lt;br /&gt;
[[File:第五课-Microduino模拟电脑键盘USB引脚焊接图.jpg|600px|center|thumb]]&lt;br /&gt;
&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：Unplug the downlaod program's USB, plug in the another USB show on schematci, open the notepad, and press the button, the notepad will show as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:第五课-Microduino模拟电脑键盘记事本显示.jpg|600px|center|thumb]]&lt;br /&gt;
&lt;br /&gt;
==Result==&lt;br /&gt;
&lt;br /&gt;
Press the button, the notepad will show &amp;quot;hello world&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==Video==&lt;br /&gt;
&lt;br /&gt;
http://v.youku.com/v_show/id_XNjgyNTUwMjA0.html&lt;/div&gt;</summary>
		<author><name>Jasonsheng</name></author>	</entry>

	</feed>