このページはEtoJ逐語翻訳フィルタによって翻訳生成されました。

翻訳前ページへ


Input 経由で Arduino serial 監視する HOME - - - - - - - - (米)棚上げする/(英)提議する of contents, my Arduino "How To" articles
Other 構成要素 for programmers    Recommend to StumbleUpon

Pt. 2 Arduino Serial 監視する

Sending data to Arduino, using serial 監視する

とじ込み/提出する:aht2serimonForInput.htm

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".

Diagram to show where Serial Monitor fits in bigger picture

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.)


The code

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.)

Image of Arduino interface

(And, just in 事例/患者, below: The old interface. The "Serial 監視する" button was the 権利 手渡す icon, the one like an upside 負かす/撃墜する window shade.)

Image of Arduino interface

That should bring up a new window, something like...

Image of Arduino Serial Monitor window

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!

If it doesn't work

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.

What's next?

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.




   Search this 場所/位置 or the web        力/強力にするd by FreeFind
 
  場所/位置 search Web search
場所/位置 地図/計画する    What's New    Search

The search engine is not intelligent. It 単に 捜し出すs the words you 明示する. It will not do anything sensible with "What does the 'could not 収集する' error mean?" It will just return 言及/関連s to pages with "what", "does", "could", "not".... etc.
In 新規加入 to the tutorials for which this page serves as (米)棚上げする/(英)提議する of Contents, I have other 場所/位置s with 構成要素 you might find useful.....

Sequenced 始める,決める of tutorials on Arduino programming and electronics interfacing.
Tutorials about the 解放する/自由な database 供給(する)d with Open Office 見解/翻訳/版 2. (If you experienced Adabas with 星/主役にする Office, ooBase is nothing like it!)
Some pages for programmers.
Using the 平行の port of a Windows computer.


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.




広告 from page's editor: Yes.. I do enjoy 収集するing these things for you... hope they are helpful. However.. this doesn't 支払う/賃金 my 法案s!!! If you find this stuff useful, (and you run an MS-DOS or Windows PC) please visit my freeware and shareware page, download something, and 循環させる it for me? Links on your page to this page would also be 高く評価する/(相場などが)上がるd!

Click here to visit editor's Sheepdog ソフトウェア (tm) freeware, shareware pages.


And if you liked that, or want different things, here are some more pages from the editor of these tutorials....

Click here to visit the homepage of my biggest 場所/位置.

Click here to visit the homepage of Sheepdogsoftware.co.uk.

Click here to visit editor's pages about using computers in Sensing and 支配(する)/統制する, e.g. 天候 logging.



To email this page's editor, Tom Boyd.... Editor's email 演説(する)/住所. Suggestions welcomed!


Valid HTML 4.01 Transitional Page 実験(する)d for 同意/服従 with INDUSTRY (not MS-only) 基準s, using the 解放する/自由な, 公然と accessible validator at validator.w3.org


Why does this page 原因(となる) a script to run? Because of the Google パネル盤s, and the code for the search button. Why do I について言及する the script? Be sure you know all you need to about spyware.

....... P a g e . . . E n d s .....