2017년 4월 4일 화요일

[Arduino Uno R3] To send text string to Serial Monitor using Serial.

1. Demo


2. Code

// the setup routine runs once when you press reset:
void setup() {
  // initialize the serial
  Serial.begin(9600);
}

// the loop routine runs over and over again forever:
int i = 0;
void loop() {
Serial.write("*** Test(");
  Serial.print(i);
  Serial.write(") ***\n");
  delay(100);
i++;
}

3. Description

 - Serial communication is to display a text string. You can see the string on the serial monitor.
 - Serial.print and Serial.println
   : Serial.print is to display a text string without '\n'
   : Serial.println is to display a text string with '\n'. '\n' means next line.
 - Serial.write
   : Serial.write can have '\n' in the text string.


4. Arduino Simulator 

 - https://circuits.io/


댓글 없음:

댓글 쓰기