Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Practical Arduino Cool Projects for Open Source Hardware- P44: 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 16 RESOURCES Add a file called keywords.txt to your library directory and list the class and functions in it. After each one add a single tab not spaces and specify whether it is a class KEYWORD1 or method KEYWORD2 . In our case we have just one class and one public method so the end result looks like this TouchScreen KEYWORD1 read KEYWORD2 If our class happened to have more methods in it they would also be labeled with KEYWORD2. The IDE will then highlight anything labeled KEYWORD1 in orange and anything labeled KEYWORD2 in brown. Restart your IDE open the example ReadTouchscreen program again and you should see that the syntax highlighting is now correct. The complete TouchScreen library is available for download from GitHub so if you want to see the end result and how it all fits together you can grab it from github.com practicalarduino TouchScreen. Platform-Specific Variations Most of the time you can write a library that will run perfectly well on just about any Arduino from a Mini to a Mega with no changes required. Sometimes though there are differences between the various Arduino models that can cause problems and the TouchScreen library we used in this example is one of them. The code as described here will work perfectly well on almost all Arduino models but will break on a Mega because it has a different system for numbering its analog and digital pins. On most Arduino models analog pins 0 through 5 can also be referenced as digital pins 14 through 19 and we do that in the library by simply adding 14 to the analog pin number to derive the digital pin number. But the Mega has far more I O pins so rather than starting the analog pins at number 14 it starts them at number 54. The result is that the code we ve created here will appear to compile cleanly on a Mega but will totally fail to work because it will be referencing the wrong pins. Luckily this problem is made very easy to solve because we used a define to specify the value for DIGITAL_OFFSET