0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[例題の為の例題]テキストの入力をする

Posted at
  • wiki 省略 EOF ... 一般的には、ASCIIコード26(0x1A)のControl-ZがEOFとして解釈される。

目的

テキストを入力したい

結果

o_coq965.jpg

プログラム




//input_teset1d_UNO_1

int incomingByte = 0;  // 受信データ用

void setup() {
  Serial.begin(9600); // 9600bpsでシリアルポートを開く
}

void loop() {

  char str1[256];

  int count_i = 0;
  while (1) { //無限ループ

    if (Serial.available() > 0) { // 受信したデータが存在する
      char ch = Serial.read(); // 受信データを読み込む
      if(ch == 26){str1[count_i]=0;break;}
      str1[count_i++] = ch;
      Serial.print(ch); // 受信データを送りかえす
    }  //endif

  }  //while
  Serial.println();
  Serial.println("input text");  //debug
  Serial.println(str1);
}


0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?