Arduino analog computer keyboard (based on the USB-HID AVR-USB device)
Reprint articles, analog input
Http://geek-workshop.com/thread-2303-1-1.html
Http://geek-workshop.com/thread-2310-1-1.html
Keyboard as a classic input device, the use of a lot of interaction has a special advantage, for example, we can pass the keyboard directly to the flash key events. Without the special interface such as serial port, although we can dismantle a traditional keyboard, then draw out the inside of the button, but this has a drawback, is the key cannot be dynamically and cannot be changed once multiple keys. Using the simulation model, we can set the button in the program free time and key. For example, this example is to press a button, the analog keyboard on the computer input "HELLO WORLD".
Hardware part:
Material list:
X1 Arduino
68 ohm resistor X2 (no 68 words, with 50~100 resistance is also OK)
2.2k ohm resistor X1 (no 2.2k words, with the 1.5k~2.2k resistance is also OK)
USB connecting line (one end is the USB port, the other end of the wire) x1
3.6V regulators (recommended power consumption 0.25~0.5w) x2
The circuit principle diagram
Circuit diagram interpretation:
1, 68 two of the resistance of the current limit and protect the role of the computer to prevent damage to the computer's USB port or the port.
2, 2.2k resistor is up pull resistance, used to distinguish the bus status. If the pull up resistor is connected to the D+ and +5v terminals, the high speed USB device is connected to the D- and +5v terminals, which is a low speed device. The keyboard transfer rate is not high here, received D- as low speed equipment can be.
3, D+ and 3.6V on the D- regulator diode D1 and D2 play a role in limiting the level of the data line. Because in the USB specification, the data line D+ and D- on the level range is 3.0V to 3.6V, and the output level of the AVR microcontroller is Vcc. If the microcontroller Vcc is 5V, in the absence of D1 and D2 will cause the level does not match, will result in a lot of computer can not correctly identify the USB device. If the user system Vcc in between 3.6V to 3.0V, you can omit the two voltage regulators. From here we can see that the user system of Vcc must be higher than 3V.
4, due to the low speed AVRUSB is needed is the 1.5MHz clock, and the single chip every 8 instructions can accurately complete a data bit collection. So AVRUSB minimum microcontroller clock frequency is 12MHz. And can use the clock frequency of 12MHz, 12.8MHz, 15MHz, 16MHz, 16.5MHz, 20MHz, the other is not supported. So if the use of the minimum system to produce this analog keyboard, then 8MHz, ATMega8L can not be used.
-- -- -- -- -- --
Software part:
Arduino support library file:
Http://soft1.wmzhe.com/download/ Ino/UsbKeyboard.zip...
UsbKeyboard.zip
After the file is downloaded to the Arduino compiler to extract the libraries folder below.
Program sample:
The following example demonstrates the application of the virtual keyboard with Arduino examples. Open Notepad, and then the D12 GND pin and connected to the Arduino, it will print the words WORLD HELLO.
Note that the first plug in the Arduino data line, the program will be written to Arduino. Then unplug the data line, the analog keyboard USB line received a computer, you can use.
The following casually point physical map
A positive and negative side
Insert data into the program into the data line Arduino:
- top
- Zero
- step
No comments:
Post a Comment