|
このページはEtoJ逐語翻訳フィルタによって翻訳生成されました。 |
Bookmark this on Delicious
Recommend to StumbleUpon
This is done in haste... 陳謝s for rough 辛勝する/優位s... The 概念s aren't コンビナート/複合体. And Libraries are exceedingly useful. Sorry I rambled on in places... just skim!
An aside: This page started life to support some pages about the NuElectronics datalogging 保護物,者. NuElectronics seems to be gone, but maybe you'll have one. To use it, you may want the "sensor_pff" library which was once upon a time 利用できる from NuElectronics. As the NuElectronics 場所/位置 had been unreachable for a while, I have put a copy of the "sensor_pff" library, as a .zip とじ込み/提出する, on my 場所/位置 for you to download. I didn't look at it very closely, if you see things in it I should not be 分配するing, please let me know. (I've no 疑問 the contents are 安全な and decent... but there may be copyright 問題/発行するs?)
The story starts with subroutines. You should be using them in your own programming to "終わりにする/要約する" things that are 論理(学)の (独立の)存在s. For instance, a 夜盗,押し込み強盗 alarm program might entail a subroutine called "RingTheBell". The subroutine would take care of the 詳細(に述べる)s, so that, "higher" in the program, when it was time for the bell to start (犯罪の)一味ing, all that would appear would be "RingTheBell()".
The story goes on to fancier subroutines which 受託する parameters and/or return values. You could, for instance, (in some other program) have a 機能(する)/行事 called AddThem, to which you pass two numbers, and from which you get 支援する the total resulting from 追加するing those number together... e.g.
int iFirst=5; int iSecond=10; iAnswer=AddThem(iFirst,iSecond);
You could, of course, 令状 such subroutines and 会社にする/組み込む them 直接/まっすぐに into your program, 特に for such simple 機能(する)/行事s, or for 機能(する)/行事s of little use beyond a 選び出す/独身 program.
Another thing you may want to do is to create new constants, types and classes. While this isn't something beginners frequently do, it is possible! (Don't worry about them, if not familiar.)
Now suppose you had some subroutines, etc, that you 手配中の,お尋ね者 to use frequently, 手配中の,お尋ね者 to use in lots of programs. With a little learning, you could create a library! 蓄える/店d in the 権利 place, it would let you put nothing more than #含む<MyLibrary.h> at the start of your program, and, through that, have 接近 to all the frequently used things that you packed away in the library!
But enough about building your own libraries! A delight for the 未来! This essay is about how you can use other people's libraries... and first, a word on why you would want to!
You'd want to because it gives you simple 接近 to some stuff that can be very useful, even though, (beneath the level you need to 関心 yourself with,) it is very コンビナート/複合体.
And there's good news: The libraries aren't tightly bound to the 残り/休憩(する) of your Arduino 開発 環境. Don't worry about messing it up.
There's a discussion of using Arduino libraries at the 公式の/役人 Arduino 場所/位置, too, of course!
As an example, we will look at 任命する/導入するing an using the infra-red 支配(する)/統制する 装置 library 利用できる from...
http://www.arcfn.com/2009/08/multi-議定書-infrared-remote-library.html
(You can also fetch that with http://tinyurl.com/ArduInfra if the tinyurl is easier for you for some 推論する/理由.)
(If you go there, you'll see something about "GitHub". I explain "GitHub" その上の 負かす/撃墜する the page.)
Like most libraries, that is 供給(する)d as a zip folder. (Some things I say in this section are 表明するd in Windows' 条件. Those of you using Linux or Mac machines will have to make allowances. Sorry.)
Before we talk about 追加するing a library, take a moment to think about how you 追加するd the Arduino IDE (統合するd 開発 環境... the ソフトウェア that lets you "do Arduino").
信用ing, you went off to the web, and downloaded something. And then you said "go", and it 始める,決める the IDE up... putting all sorts of "stuff" on your hard 運動. And then you 開始する,打ち上げるd the IDE, and a program ran on your computer doing... you really don't know what, do you?
But the Arduino IDE, and the 場所/位置 it comes from, have been around for a long time, and if it did Bad Things, we'd probably know about it by now.
You don't, I hope, rummage around obscure corners of your hard 運動, 削除するing things when you don't know what they are? That way lies MANY 涙/ほころびs! You really need to know a lot about something before you can say it is not important. Not knowing what something is is a world away from knowing it is not important. Modern computer systems became way too コンビナート/複合体 for that, a long time ago.
So... if you want to be careful about what is on your machine... good luck to you. But we have to try.
There are many excellent third party libraries out there in internet-land. But there are probably some Bad Things lurking out there too, "wolves" in "nice third party library" 着せる/賦与するing.
So here's how I prefer to proceed....
If I hear of a library, I am much more likely to give it a try if I can download a .zip, unzip that to a "scratch" folder, and have a little look around the code. (After scanning it with my anti-malware support, of course.)
And Arduino libraries should be very "happy" to let me (or you) do this. Most (all?) will 伴う/関わる an .h とじ込み/提出する and a .cpp とじ込み/提出する. Maybe more than one. にもかかわらず the 拡張s (.h, .cpp), these are just text とじ込み/提出するs. Open them with whatever text editor you like. (I'm a longtime fan of TextPad. 解放する/自由な evaluation デモ, without silly 抑制s.)
Anyway... though I can't make sense of all I read in these とじ込み/提出するs... the fact that nothing is hidden 大いに 安心させるs me.
There's a second 問題/発行する here, too: If I 任命する/導入する this library, and later want to, say, move my Arduino work to a second computer, or 昇格 to a newer 見解/翻訳/版 of the IDE, will the library still be 利用できる? 井戸/弁護士席, yes... If I've kept the とじ込み/提出するs. They aren't "体制/機構 とじ込み/提出するs". Nothing obscure has to be "done" to "任命する/導入する" them. They just have to be 現在の on your hard 運動, in a place that the IDE knows about. (More on that latter bit in a moment.)
Now. That's only half of the 問題/発行するs. My wants and worries have been taken care of.
The IDE isn't 魔法. And humans are unreliable. So いつか around 2015 the Arduino IDE had a big 改良 会社にする/組み込むd.
Before the 改良, 追加するing a library was a bit of a "thing". You either 信用d an "任命する/導入する" 決まりきった仕事, or you had to put copies of things in "the 権利 place", and manage what "the 権利 place" was.
Now it is all very much better.
You still have as much 支配(する)/統制する as you like over "what's on my computer". And total freedom to 古記録 everything associated with a new library. But the IDE will "take a copy" of "the stuff", for its 目的s. Here's how I manage the 過程 of keeping me AND the IDE happy....
When I see a library I want to use, I fetch the .zip. In whatever place you like, you should keep a copy of the .zip, and a folder with what was in the zip, unzipped. (The latter is not ENTIRELY necessary... but can be helpful.)
As について言及するd before, the .zip may 含む/封じ込める more than just the とじ込み/提出するs 必須の to the library. There will often be デモ programs, and いつかs text 文書s telling you what the features of the library are, and how to use them.
I keep my third party libraries in a folder called "ThirdPartyLibs", with a separate folder for each one. When I'm 存在 really efficient, I 追加する a little text とじ込み/提出する to the folder, 公式文書,認めるing where the contents (機の)カム from.
Within the folder 献身的な to a given library (that folder itself 存在 inside "ThirdPartyLibs"), I create a folder "Unzipped", and put (you can 人物/姿/数字 it out!) in that.
NOW comes the clever bit...
So far it has been all about my wants. Now we're going to 演説(する)/住所 the IDS's wants.
解雇する/砲火/射撃 up the IDE. (The に引き続いて "blow-by-blow was 草案d in March 17 using Arduino 1.8.1 on a Windows 7 PC.)
Invoke Sketch/ 含む Library/ 追加する .Zip Library
Don't worry! Although you CAN 追加する a library 直接/まっすぐに from a .zip とじ込み/提出する, if you wish, the same path takes you to the 過程 for 追加するing library とじ込み/提出するs which have already been 抽出するd from any .zip とじ込み/提出する they may have been in.
If you are 追加するing a library using un-zipped とじ込み/提出するs, change the "とじ込み/提出するs Of Type" field at the 底(に届く) of the "Open" dialog which doing what I've told you should have brought up on your 審査する. Change it to "All とじ込み/提出するs".
Navigate to the folder with the とじ込み/提出するs that 構成する the library you want to have 利用できる to your Arduino programming.
(Don't worry about selecting any of them...) Just click the Open button, once you've navigated to the 権利 folder.
The Arduino IDE will take COPIES of the とじ込み/提出するs, put them where it needs them. Yes...this is almost the "let it do (mysterious) things" that I don't like about ordinary 任命する/導入するs. I don't know WHERE the IDE will put those copies, what (Arduino IDE) config とじ込み/提出するs it will mess with. But at least I have backup copies of the necessary とじ込み/提出するs, and I know what went "into" the Arduino IDE 取り付け・設備 on my machine!
That's it! Library ready for use! You don't have to 再開する the IDE. You certainly don't have to 再開する the PC. Just use "Sketch/ 含む Library", and scroll 負かす/撃墜する through the libraries 利用できる until you come to the one you just 任命する/導入するd!
Here's how you USE a new library, once it is in place. Really 平易な!
The library's web page will almost certainly have examples and documentation. There may be example programs within the .zip the library (機の)カム in, often within a sub-folder called "examples".
In every 事例/患者, you will have to 追加する a line (or more) to the start of the program that is going to use any subroutines, etc, 供給するd by the library. (デモs will probably have the necessary line in them already.)
Remember the good news: You don't have to know HOW the library does the things it does. You just have to know "the new words" that the library has "追加するd" to your Arduino's "language". In the 事例/患者 of the IR library we've been discussing, one such new word is "SendSony". If you had an IR LED (and 現在の 限界ing resistor) connected to pin 12 of your Arduino, and said "sendSony(0xA90,12);" the LED would "flash" 正確に/まさに like the IR LED in a Sony remote 支配(する)/統制する sending hex A90. (The "0x" ("無 ex", not "oh ex") says "number in hex follows"). Don't worry now about what "hex" is, or why you would want to send hex A90... just 信用 me on that one... you might want to one day! And when that day comes, the library makes it all REALLY 平易な.
現実に, I've 簡単にするd things a little. You'd 現実に need to say something like....
MyIR.sendSony(0xA90,12);
We'll come 支援する to the "MyIR." part in a moment. First I'd like to 強調する/ストレス that the "sendSony()" has to be 正確に/まさに as shown. That was defined in the library, and you can't easily change it. In the 事例/患者 of sendSony, there needs to be two numbers, separated by a comma, inside the parentheses. I told you earlier what they 明示する. How did I know that the word was sendSony, and that the numbers are done like this? By looking at the example 供給(する)d with the library.
Now for the "MyIR." part.
Also within the library a class called IRsend was created. Again, that 指名する is pretty inflexible. 早期に on in my program, but after the #含む<> we'll discuss in a moment (last "new" thing"), you need to put something like...
IRsend MyIR;
You can't change the first word; the second word is something you choose. Once you have this line in your program, you can (and should) put the 同等(の) of "MyIR." in 前線 of words which come from the IRsend class, which was 始める,決める up for you inside the IRremote library. I'm new to C, and don't know the C-speak (which is also Arduino-speak) for the 概念s, but in 平行の universes, we would say that with "IRsend MyIR;" you are creating an instance of an 反対する of class "IRsend". IRsend is a 概念, defined within the library. "概念s" are hard to work with. "政治家" is a 概念. Nelson Mandela is an instance of a 政治家. A 明確な/細部, 指名するd instance. One you can work with. Notice that "IRsend MyIR;" looks and 作品 almost like, say, "int iTmp;", which would create a variable called iTmp, of the type "int". You can't change the word "int", but you can (不足などを)補う the 指名する you want for the instance of an int type variable that you want to use in your program.
And now for the last thing.
If you just put "IRsend MyIR;" in your program, the compiler will complain. It hasn't heard of the "IRsend" class, can't make an instance of it. That's where the....
#含む<IRremote.h>
... line comes in. You put it at the start of your program. With that in place, your program will 収集する. The Arduino compiler looks through all the words it knows before giving up on 収集するing something, and it looks in any libraries it has been told to check... for this program. The "#含む<IRremote.h>" was where you told the compiler about the extra place to look for things. (You can 含む more than one library in a 事業/計画(する), by the way, so the compiler will look in 多重の places.)
A moment ago I told you to put the "#含む<IRremote.h>" line in. But you don't have to type it by 手渡す. If you have the library 適切に 任命する/導入するd on your system, all you have to do is click on the "Sketch" menu item, and then the "輸入する library..." item on the sub-menu that arises. Then click on the 指名する of the library you want your program to 会社にする/組み込む. All that does is to 追加する the "#含む<IRremote.h>" line in your code. But it doesn't make typos. And it makes sure that the library you want to use is 現実に 現在の. And it puts the line at the 最高の,を越す of the とじ込み/提出する, which is pretty 井戸/弁護士席 the 権利 place. If you want it below a few rems, that's okay, but leave it 近づく the 最高の,を越す. Might 同様に use the "輸入する library..." convenience. Don't be worried about "What is this doing to my code? What problems will be 追加するd that I don't even know where to go looking to 直す/買収する,八百長をする?"
I 設立する the menu item's text, "輸入する library" 混乱させるing. The 開発 環境 is not talking about 輸入するing or 任命する/導入するing a new library into the 開発 環境. You do that 分かれて, once and for all. (Explained above.) The "Sketch / 輸入する Library" 機能(する)/行事 is 単に 追加するing the 権利 line of code (the "含む" line) to your program, so that the compiler will know where to look for the "extra features" (from the library) you want to avail yourself of!
- - - - - - - - - - - - -
GitHub has been around for a long time. I know lots of sensible people use it, like it. I'm not terribly familiar with it.
Not infrequently, if you want a third party library, you will be sent to a GitHub page, which may look a bit like...
... 井戸/弁護士席. May look like that, after you discover "the trick".
Don't be put off by what looks like a directory structure, on the left. You don't need that. What you do need to do is make your browser window wide enough for the "Clone or Download" button to appear. In the image above, you see what you should see after you click that. Having clicked the small 黒人/ボイコット "Clone or download", select the bigger, blue, "Download Zip"... and you will... download the zip! 平易な. Once you find the "download" button!
-------------------
その上の to the Arduino ideas the page you are reading now will take you to, I have 地位,任命するd a 一連の essays which try to help you become a better Arduino programmer and engineer... but, for the best result, you will have to buckle 負かす/撃墜する and work your way through them in sequence. The "How To's" here can be 接近d in whatever order you like.
Feel 解放する/自由な to use this (警察などへの)密告,告訴(状) in programming courses, etc, but a credit of the source would be 高く評価する/(相場などが)上がるd. If you 簡単に copy the pages to other web pages you will do your readers a disservice: Your copies won't stay 現在の. Far better to link to these pages, and then your readers see up-to-date 見解/翻訳/版s. For those who care- thank you- I have 地位,任命するd a page with more (警察などへの)密告,告訴(状) on what copyright 権利放棄s I 延長する, and suggestions for those who wish to put this 構成要素 on CDs, etc.
Have you heard of Flattr? 広大な/多数の/重要な new idea to make it 平易な for you to send small thank you$ to people who 供給する Good Stuff on the web. If you want to send $$erious thank yous, there are better ways, but for a small "tip" here and there, Flattr ticks a lot of boxes which no one else has 設立する a way to do yet. Please at least check out my introduction to Flattr, if you 港/避難所't heard of it? "No 義務", as they say!
See the discussion 近づく the 底(に届く) of the "最高の,を越す level" page covering the 本体,大部分/ばら積みの of my Arduino 出資/貢献s. There is (警察などへの)密告,告訴(状) there, too, about things like "May I copy your 構成要素?", and the system of とじ込み/提出する 指名するs I am trying to work to.
If you visit 1&1's 場所/位置 from here, it helps me. They host my website, and I wouldn't put this link up for them if I wasn't happy with their service... although I was いっそう少なく than pleased the other day to have what I was doing interrupted by a telephone call from their sales team, trying to get me to 延長する my 関与. Sigh. Hardly a rare event, but I'd thought 1&1 were a bit classier that some of the people who have my telephone number.
Click here to visit editor's Sheepdog ソフトウェア (tm) freeware, shareware pages.
Click here to visit the homepage of my biggest 場所/位置.
Click here to visit the homepage of Sheepdogsoftware.co.uk. 陳謝s if the "?Frmar3ne1libs" I 追加するd to that link 原因(となる)s your browser problems. Please let me know, if so?
Page 実験(する)d for 同意/服従 with INDUSTRY (not MS-only) 基準s, using the 解放する/自由な, 公然と accessible validator at validator.w3.org. Mostly passes. There were two "unknown せいにするs" in Google+ button code. Sigh.
....... P a g e . . . E n d s .....