tailieunhanh - Practical Arduino Cool Projects for Open Source Hardware- P9
Practical Arduino Cool Projects for Open Source Hardware- P9: A schematic or circuit diagram is a diagram that describes the interconnections in an electrical or electronic device. In the projects presented in Practical Arduino, we’ve taken the approach of providing both a photograph and/or line drawing of the completed device along with a schematic. While learning to read schematics takes a modest investment of your time, it will prove useful time and time again as you develop your projects. With that in mind, we present a quick how-to in this section | CHAPTER 4 VIRTUAL USB KEYBOARD As you can see from the sequence sent when BUTTON_MSG is asserted you aren t limited to sending one keypress event per input you can also send sequences of characters. Finally the sketch defines its own delay function that can be used inside setup while timer0 is disabled. void delayMs unsigned int ms for int i 0 i ms i delayMicroseconds 1000 One thing to note about the example sketch is that it doesn t introduce any delays inside the main program loop. It s critical that the loop executes quickly so just about the only thing you can do inside the loop is read digital inputs if you try to do anything that will slow down the program the host computer may fail to get a response at a critical time and decide the device is misbehaving. If that happens the host will de-enumerate the device and your fake keyboard will stop working. Once you ve compiled the sketch and uploaded it to your Arduino open a new document in a text editor or word processor on the host computer so it s all ready for your Arduino to begin typing into it. Then disconnect the USB lead from the normal USB socket on the Arduino board and plug it instead into the additional USB socket on the prototyping shield. This will cause the Arduino to power down and then power up again using power from the USB connection coming in via the shield. It will also attempt to enumerate itself with the host computer as a Human Interface Device HID so if you re curious about what happens you could open the system log on your computer and watch it while plugging the USB cable into the shield. If all goes well your Arduino will now behave like an extra keyboard plugged into your computer so try pressing one of the buttons or connecting one of the inputs to ground to trigger a keypress event. You should see corresponding characters appear in the text document on your computer and as far as it knows that s just you typing the letters on a regular keyboard For a more complete list of available
đang nạp các trang xem trước