Difference between revisions of "Microduino Rotary encoder controls computer"

From Microduino Wiki
Jump to: navigation, search
(Created page with "{{Language | Microduino 旋转编码器控制电脑}} {| style="width: 800px;" |- | ==Outline== *Project:Microduino encoder controls the computer *Objective:Use the Microd...")
 
 
(3 intermediate revisions by 2 users not shown)
Line 4: Line 4:
 
|
 
|
 
==Outline==
 
==Outline==
*Project:Microduino encoder controls the computer
+
*Project: Microduino encoder controls computer
*Objective:Use the Microduino-32U4 and rotary encoder to simulate the keyboard. Press it to simulate the "Ctrl+tab", and rotate it to move the windows (up and down).
+
*Objective: Use the Microduino-32U4 and rotary encoder to simulate the keyboard. Press it to simulate the "Ctrl+tab", and rotate it to move the windows (up and down).
*Difficulty:Higt
+
*Difficulty: High
*Time-consuming:3 hours
+
*Time-consuming: 3 hours
*Maker:Microduino Studio-PKJ
+
*Maker: Microduino Studio-PKJ
  
 
==Bill of Materials==
 
==Bill of Materials==
Line 35: Line 35:
 
http://www.microduino.cc/wiki/index.php?title=%E5%AE%89%E8%A3%85Arduino_IDE_Microduino%E7%A1%AC%E4%BB%B6%E6%94%AF%E6%8C%81%E5%8C%85
 
http://www.microduino.cc/wiki/index.php?title=%E5%AE%89%E8%A3%85Arduino_IDE_Microduino%E7%A1%AC%E4%BB%B6%E6%94%AF%E6%8C%81%E5%8C%85
  
Download test program:
+
Download test program:
 
https://github.com/Microduino/Microduino_Tutorials/tree/master/Microduino_Advanced_Tutorial/Microduino_32u4_KEY
 
https://github.com/Microduino/Microduino_Tutorials/tree/master/Microduino_Advanced_Tutorial/Microduino_32u4_KEY
  
 
==Debug==
 
==Debug==
*Prepare:
+
*Prepare:
*Download Microduino frimware package, uncompress to hardware folder of IDE;
+
*Download Microduino frimware package, unzip to hardware folder of IDE;
*Step 1:Set up system, as follows:
+
*Step 1: Set up system, as follows:
 
[[File:rotary_encoder_setup.jpg|600px|center|thumb]]
 
[[File:rotary_encoder_setup.jpg|600px|center|thumb]]
*Step 2:Open the test program, compile it and download.
+
*Step 2: Open the test program, compile it and download.
 
[[File:rotary_encoder_download.jpg|600px|center|thumb]]
 
[[File:rotary_encoder_download.jpg|600px|center|thumb]]
*Step 3:After download, use the encoder to control.
+
*Step 3: After download, use the encoder to control.
 
==Program explanation==
 
==Program explanation==
 
Use Arduino's USB library to relize the keyboard data input.
 
Use Arduino's USB library to relize the keyboard data input.
Line 51: Line 51:
 
1.Function "Keyboard.write();" means that only press key one time. Function "Keyboard.press()" means that always hold the key, to cooperate with function "Keyboard.releaseAll()" used together;
 
1.Function "Keyboard.write();" means that only press key one time. Function "Keyboard.press()" means that always hold the key, to cooperate with function "Keyboard.releaseAll()" used together;
  
2.Input case alphanumeric directly and use single quotation to mark. For example, input character "M""Keyboard.write(‘M’);". Input special key, you can find the key nambe in file "hardware\arduino\cores\arduino\USBAPI.h", if you want to input "enter", just like this:"Keyboard.write(KEY_RETURN);".
+
2.Input case alphanumeric directly and use single quotation to mark. For example, input character "M": "Keyboard.write('M');". Input special key, you can find the key nambe in file "hardware\arduino\cores\arduino\USBAPI.h", if you want to input "enter", just like this:"Keyboard.write(KEY_RETURN);".
  
 
3.Read the I/O port voltage to judge the if the encoder was pressed which use to simulate the "Ctrl+Tab".
 
3.Read the I/O port voltage to judge the if the encoder was pressed which use to simulate the "Ctrl+Tab".
Line 62: Line 62:
  
 
==Result==
 
==Result==
Rotary encoder simulates the keyboard to relize the un and down key. Press the encoder to simulate the "Ctri+tab". You change the key value to finish other experiment.
+
Rotary encoder simulates the keyboard to realize the up and down key. Press the encoder to simulate the "Ctri+tab". You change the key value to finish other experiment.
  
 
==Pay attention issue==
 
==Pay attention issue==
Line 69: Line 69:
  
 
==Video==
 
==Video==
 
+
http://v.youku.com/v_show/id_XNzAwNjQ3MDQw.html
 
|}
 
|}

Latest revision as of 08:49, 13 September 2016

Language: English  • 中文

Outline

  • Project: Microduino encoder controls computer
  • Objective: Use the Microduino-32U4 and rotary encoder to simulate the keyboard. Press it to simulate the "Ctrl+tab", and rotate it to move the windows (up and down).
  • Difficulty: High
  • Time-consuming: 3 hours
  • Maker: Microduino Studio-PKJ

Bill of Materials

  • Microduino equipment
Module Number Function
Microduino-Core 1 Core module
Microduino-FT232R 1 Download program
Microduino-32U4 1 Simulate keyboard and core module
  • Other equipment
rotary encoder 1 Simulate the keyboard command
USB cable 1 Power for core module

Document

Download Microduino firmware package: http://www.microduino.cc/wiki/index.php?title=%E5%AE%89%E8%A3%85Arduino_IDE_Microduino%E7%A1%AC%E4%BB%B6%E6%94%AF%E6%8C%81%E5%8C%85

Download test program: https://github.com/Microduino/Microduino_Tutorials/tree/master/Microduino_Advanced_Tutorial/Microduino_32u4_KEY

Debug

  • Prepare:
  • Download Microduino frimware package, unzip to hardware folder of IDE;
  • Step 1: Set up system, as follows:
Rotary encoder setup.jpg
  • Step 2: Open the test program, compile it and download.
Rotary encoder download.jpg
  • Step 3: After download, use the encoder to control.

Program explanation

Use Arduino's USB library to relize the keyboard data input.

1.Function "Keyboard.write();" means that only press key one time. Function "Keyboard.press()" means that always hold the key, to cooperate with function "Keyboard.releaseAll()" used together;

2.Input case alphanumeric directly and use single quotation to mark. For example, input character "M": "Keyboard.write('M');". Input special key, you can find the key nambe in file "hardware\arduino\cores\arduino\USBAPI.h", if you want to input "enter", just like this:"Keyboard.write(KEY_RETURN);".

3.Read the I/O port voltage to judge the if the encoder was pressed which use to simulate the "Ctrl+Tab".

4.Use the interrupt to judge the directory of encoder, then choose the value. We have changed the firmware, so you need download Microduino's firmware package.

5.doEncoder() use to simulate the up and down key.

6.In main function to judge if the encoder was pressed to simulate "Ctrl+Tab".

Result

Rotary encoder simulates the keyboard to realize the up and down key. Press the encoder to simulate the "Ctri+tab". You change the key value to finish other experiment.

Pay attention issue

  • Compile the program must use the 32U4, because only 32U4 can support USB protocol.
  • Need download latest Microduino firmware package.

Video

http://v.youku.com/v_show/id_XNzAwNjQ3MDQw.html