<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://lms.onnocenter.or.id/wiki/index.php?action=history&amp;feed=atom&amp;title=Arduino%3A_Serial_Event</id>
	<title>Arduino: Serial Event - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://lms.onnocenter.or.id/wiki/index.php?action=history&amp;feed=atom&amp;title=Arduino%3A_Serial_Event"/>
	<link rel="alternate" type="text/html" href="https://lms.onnocenter.or.id/wiki/index.php?title=Arduino:_Serial_Event&amp;action=history"/>
	<updated>2026-04-20T16:49:56Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://lms.onnocenter.or.id/wiki/index.php?title=Arduino:_Serial_Event&amp;diff=45282&amp;oldid=prev</id>
		<title>Onnowpurbo: New page: Sumber: https://www.arduino.cc/en/Tutorial/SerialEvent   This example demonstrates use of the SerialEvent() function. This function is called inside the loop(). If there is serial data in ...</title>
		<link rel="alternate" type="text/html" href="https://lms.onnocenter.or.id/wiki/index.php?title=Arduino:_Serial_Event&amp;diff=45282&amp;oldid=prev"/>
		<updated>2015-12-09T11:21:49Z</updated>

		<summary type="html">&lt;p&gt;New page: Sumber: https://www.arduino.cc/en/Tutorial/SerialEvent   This example demonstrates use of the SerialEvent() function. This function is called inside the loop(). If there is serial data in ...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Sumber: https://www.arduino.cc/en/Tutorial/SerialEvent&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This example demonstrates use of the SerialEvent() function. This function is called inside the loop(). If there is serial data in the buffer each character found is added to a string until a newline is found. In this case the string made by the characters received so far is printed and set back to null. &lt;br /&gt;
&lt;br /&gt;
==Hardware==&lt;br /&gt;
&lt;br /&gt;
* Arduino or Genuino Board &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&lt;br /&gt;
 /*&lt;br /&gt;
   Serial Event example&lt;br /&gt;
 &lt;br /&gt;
  When new serial data arrives, this sketch adds it to a String.&lt;br /&gt;
  When a newline is received, the loop prints the string and&lt;br /&gt;
  clears it.&lt;br /&gt;
 &lt;br /&gt;
  A good test for this is to try it with a GPS receiver&lt;br /&gt;
  that sends out NMEA 0183 sentences.&lt;br /&gt;
 &lt;br /&gt;
  Created 9 May 2011&lt;br /&gt;
  by Tom Igoe&lt;br /&gt;
 &lt;br /&gt;
  This example code is in the public domain. &lt;br /&gt;
 &lt;br /&gt;
  http://www.arduino.cc/en/Tutorial/SerialEvent&lt;br /&gt;
 &lt;br /&gt;
  */&lt;br /&gt;
 &lt;br /&gt;
 String inputString = &amp;quot;&amp;quot;;         // a string to hold incoming data&lt;br /&gt;
 boolean stringComplete = false;  // whether the string is complete&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
   // initialize serial:&lt;br /&gt;
   Serial.begin(9600);&lt;br /&gt;
   // reserve 200 bytes for the inputString:&lt;br /&gt;
   inputString.reserve(200);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
   serialEvent(); //call the function&lt;br /&gt;
   // print the string when a newline arrives:&lt;br /&gt;
   if (stringComplete) {&lt;br /&gt;
     Serial.println(inputString);&lt;br /&gt;
     // clear the string:&lt;br /&gt;
     inputString = &amp;quot;&amp;quot;;&lt;br /&gt;
     stringComplete = false;&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 /*&lt;br /&gt;
  SerialEvent occurs whenever a new data comes in the&lt;br /&gt;
  hardware serial RX.  This routine is run between each&lt;br /&gt;
  time loop() runs, so using delay inside loop can delay&lt;br /&gt;
  response.  Multiple bytes of data may be available.&lt;br /&gt;
  */&lt;br /&gt;
 void serialEvent() {&lt;br /&gt;
   while (Serial.available()) {&lt;br /&gt;
     // get the new byte:&lt;br /&gt;
     char inChar = (char)Serial.read();&lt;br /&gt;
     // add it to the inputString:&lt;br /&gt;
     inputString += inChar;&lt;br /&gt;
     // if the incoming character is a newline, set a flag&lt;br /&gt;
     // so the main loop can do something about it:&lt;br /&gt;
     if (inChar == &amp;#039;\n&amp;#039;) {&lt;br /&gt;
       stringComplete = true;&lt;br /&gt;
     }&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Referensi==&lt;br /&gt;
&lt;br /&gt;
* https://www.arduino.cc/en/Tutorial/SerialEvent&lt;/div&gt;</summary>
		<author><name>Onnowpurbo</name></author>
	</entry>
</feed>