|
このページはEtoJ逐語翻訳フィルタによって翻訳生成されました。 |
This is one of a number of articles which 試みる/企てる to help people have fun with Arduinos.
It 演説(する)/住所s a use of the いつかs under-used "serial 監視する", which is a ソフトウェア 道具 built into the Arduino IDE.
It follows on from an earlier article which introduced the Arduino serial 監視する. The earlier article showed you how to send text to the serial 監視する. (By the way... there's also a 道具 which draws graphs from numbers from the Arduino. That's 接近d 経由で 道具s/Serial Plotter.)
In this article, I will show you how to send data in the other direction... You'll type things on keyboard of the laptop in the middle of the illustration, and the Arduino will "see" what you typed as soon as you 圧力(をかける) "enter".
Look at the 権利-手渡す third of the illustration. It shows the serial 監視する window, 大きくするd. The text you see is a 見本 of 生産(高) from the Arduino. That text was 明示するd in the code put into the Arduino under 開発. But we're not doing that today.
Besides letting you see messages from the Arduino, the serial 監視する also 許すs you to send things to the Arduino.
Sadly perhaps, but やむを得ず I 嫌疑者,容疑者/疑う, 圧力(をかける)ing a 重要な (or two, or more) doesn't send it to the Arduino すぐに. Your input is only sent when you then 圧力(をかける) the "enter" 重要な. The upside of this is that if you want to send, say, "Hello Arduino", you can type that... getting it 権利 along the way (hurrah for the backspace 重要な!), and then send the "finished message" at the moment of your choosing.
We're going to create a tiny program, just to illustrate the basics. For that you only need an Arduino with an LED on pin 13. Thus, most people won't need to connect anything, as most Arduinos have a built-in LED on pin 13.
==============
The "bad news"? (Obvious(?) when you think about it.) This approach to sending characters to the Arduino only 作品 when it is 麻薬中毒の up to "the big computer" used for programming the Arduino. (If you want to connect a keyboard to an Arduino, for use when it is not connected to the big computer, have a look at the USB Host 監査役 Board V2.4, which you can buy (&続けざまに猛撃する;15, +p&p, 2/17) pre-負担d with a USB Keyboard to serial stream of ASCII from Hobbytronics.co.uk.)
Don't be alarmed at how "long" the に引き続いて is... a lot of it is just comments!
(When 見解(をとる)ing this on some 装置s, you may have to scroll 負かす/撃墜する the page a little to see the code....)
V
V
/*Ar796-v1-0 * 見解/翻訳/版: 06 Feb 18 * Started: 06 Feb 18 * * デモ getting input from big PC's keyboard, * using Serial 監視する * *Derived from the very (疑いを)晴らす tutorial at... *https://startingelectronics.org/ソフトウェア/ * arduino/learn-to-program-course/19-serial-input/ * *The LED was put on pin 13 to take advantage of the * "built in" LED 現在の on many Arduinos. No * other 外部の 金物類/武器類 is needed. * *The program only "作品" when the Arduino is 麻薬中毒の * up to the Arduino, running in a "big" computer. * *You need to open the Serial 監視する window, and click * in the edit box 近づく the 最高の,を越す of that. 圧力(をかける) "a" * and "enter", and the LED should flash. * *Serial 監視する: *http://sheepdogguides.com/arduino/aht1serimoni.htm */ const byte pLED0=13; char chFrmSerial; 無効の 体制/機構() { pinMode(pLED0,OUTPUT); chFrmSerial=0; Serial.begin(9600); }//end of 体制/機構() 無効の 宙返り飛行() {2 if (Serial.利用できる() > 0) { // Is a character 利用できる? //公式文書,認める: It won't be "利用できる" as soon as you type it... // You have to 圧力(をかける) "enter". THEN the whole line is // sent, be it one letter or more. (They would be sent // one letter at a time. chFrmSerial = Serial.read(); // There was! Get the character //Now use it... if (chFrmSerial="a"){ digitalWrite(pLED0,HIGH); 延期する(30); digitalWrite(pLED0,LOW); //Think: Why no "延期する(30)" here? }//end of if chSerial=='a' } // end: if (Serial.利用できる() > 0) }// end of 宙返り飛行()
Wait until the usual "Binary sketch size..." message comes up in the pane at the 底(に届く) of the Arduino 統合するd 開発 環境 ("IDE"). Then click on the "Serial 監視する" button, the "magnifying glass" I 示すd it "6" in the diagram below. (It shows the 最高の,を越す of the Arduino IDE window.)
(And, just in 事例/患者, below: The old interface. The "Serial 監視する" button was the 権利 手渡す icon, the one like an upside 負かす/撃墜する window shade.)
That should bring up a new window, something like...
Click in the 狭くする 禁止(する)d ("edit box") at the 最高の,を越す of the Serial 監視する window. The box just to the left of the "Send" button. On your big computer's keyboard, type an "a". Watch the LED on the Arduino, and, still watching that, 圧力(をかける) the "enter" 重要な. The LED should flash... and I hope you can see what made that happen?
That's it! 抑えるのをやめる your creativity!
A few things that might get in the way...
a) Remember: The text in the edit box is not sent until you 圧力(をかける) the big computer's "enter" 重要な. (Clicking the "Send" button is as good. Try that!)
b) In the program as 現在のd, you can see Serial.begin(9600).
Look again at the most 最近の graphic. See "9600" in the lower left? That can be 始める,決める to a different number, if you have 推論する/理由 to do so. But the number there and in the Serial.begin line must match.
c) 近づく the "9600" we were just talking about, you can see "No line ending". What's there shouldn't 事柄 to our simple use of the serial 監視する to send data to the Arduino, but I hope you will go beyond our simple use! When you do, you may or may not want to leave the setting at "No line ending". I would tend to leave it thus.
The program 現在のd is, of course, very, very simple, 天然のまま.
What's next is up to you! Now that you know how to send characters to the Arduino from "the big computer", I hope you will find the 技術 let's you create programs that do things which amuse you... or at least are useful.
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.
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.
Page 実験(する)d for 同意/服従 with INDUSTRY (not MS-only) 基準s, using the 解放する/自由な, 公然と accessible validator at validator.w3.org
....... P a g e . . . E n d s .....