<?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_Ethernet_TCP_Read_Data</id>
	<title>Arduino: Ethernet TCP Read Data - 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_Ethernet_TCP_Read_Data"/>
	<link rel="alternate" type="text/html" href="https://lms.onnocenter.or.id/wiki/index.php?title=Arduino:_Ethernet_TCP_Read_Data&amp;action=history"/>
	<updated>2026-04-20T14:18:08Z</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:_Ethernet_TCP_Read_Data&amp;diff=45771&amp;oldid=prev</id>
		<title>Onnowpurbo at 04:55, 23 February 2016</title>
		<link rel="alternate" type="text/html" href="https://lms.onnocenter.or.id/wiki/index.php?title=Arduino:_Ethernet_TCP_Read_Data&amp;diff=45771&amp;oldid=prev"/>
		<updated>2016-02-23T04:55:27Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 04:55, 23 February 2016&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l35&quot;&gt;Line 35:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 35:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  // Set values below to match your network needs:&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  // Set values below to match your network needs:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  byte mac[] = {0x54, 0x52, 0x49, 0x41, 0x44, 0x00};   // MAC Address&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  byte mac[] = {0x54, 0x52, 0x49, 0x41, 0x44, 0x00};   // MAC Address&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  byte ip[] = {192, 168, 0, &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;3&lt;/del&gt;};                        // Network Address&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  byte ip[] = {192, 168, 0, &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;4&lt;/ins&gt;};                        // Network Address&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  byte gateway[] = {192, 168, 0, 223};                 // Gateway Address&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  byte gateway[] = {192, 168, 0, 223};                 // Gateway Address&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  byte subnet[] = {255, 255, 255, 0};                  // Subnet Mask&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  byte subnet[] = {255, 255, 255, 0};                  // Subnet Mask&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Onnowpurbo</name></author>
	</entry>
	<entry>
		<id>https://lms.onnocenter.or.id/wiki/index.php?title=Arduino:_Ethernet_TCP_Read_Data&amp;diff=45267&amp;oldid=prev</id>
		<title>Onnowpurbo at 04:45, 8 December 2015</title>
		<link rel="alternate" type="text/html" href="https://lms.onnocenter.or.id/wiki/index.php?title=Arduino:_Ethernet_TCP_Read_Data&amp;diff=45267&amp;oldid=prev"/>
		<updated>2015-12-08T04:45:59Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 04:45, 8 December 2015&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l35&quot;&gt;Line 35:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 35:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  // Set values below to match your network needs:&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  // Set values below to match your network needs:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  byte mac[] = {0x54, 0x52, 0x49, 0x41, 0x44, 0x00};   // MAC Address&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  byte mac[] = {0x54, 0x52, 0x49, 0x41, 0x44, 0x00};   // MAC Address&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  byte ip[] = {&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;10&lt;/del&gt;, &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;0&lt;/del&gt;, 0, &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;47&lt;/del&gt;}; &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;                         &lt;/del&gt;// Network Address&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  byte ip[] = {&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;192&lt;/ins&gt;, &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;168&lt;/ins&gt;, 0, &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;3&lt;/ins&gt;}; &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;                       &lt;/ins&gt;// Network Address&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  byte gateway[] = {&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;10&lt;/del&gt;, &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;0&lt;/del&gt;, 0, &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;1&lt;/del&gt;}; &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;                     &lt;/del&gt;// Gateway Address&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  byte gateway[] = {&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;192&lt;/ins&gt;, &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;168&lt;/ins&gt;, 0, &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;223&lt;/ins&gt;}; &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;                &lt;/ins&gt;// Gateway Address&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  byte subnet[] = {255, 255, 255, 0};                  // Subnet Mask&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  byte subnet[] = {255, 255, 255, 0};                  // Subnet Mask&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  EthernetServer server(23);                           // Set Server Port&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  EthernetServer server(23);                           // Set Server Port&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Onnowpurbo</name></author>
	</entry>
	<entry>
		<id>https://lms.onnocenter.or.id/wiki/index.php?title=Arduino:_Ethernet_TCP_Read_Data&amp;diff=45266&amp;oldid=prev</id>
		<title>Onnowpurbo: New page: Sumber: http://forum.arduino.cc/index.php?topic=123756.0     ==Code==   /*      Ethernet TCP client/server communications test/proof of concept      Programmed by Michael E. Landon on 09/2...</title>
		<link rel="alternate" type="text/html" href="https://lms.onnocenter.or.id/wiki/index.php?title=Arduino:_Ethernet_TCP_Read_Data&amp;diff=45266&amp;oldid=prev"/>
		<updated>2015-12-08T04:45:08Z</updated>

		<summary type="html">&lt;p&gt;New page: Sumber: http://forum.arduino.cc/index.php?topic=123756.0     ==Code==   /*      Ethernet TCP client/server communications test/proof of concept      Programmed by Michael E. Landon on 09/2...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Sumber: http://forum.arduino.cc/index.php?topic=123756.0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&lt;br /&gt;
 /*&lt;br /&gt;
     Ethernet TCP client/server communications test/proof of concept&lt;br /&gt;
     Programmed by Michael E. Landon on 09/20/2012&lt;br /&gt;
     (With parts borrowed/stolen from Nick Gammon)&lt;br /&gt;
     &lt;br /&gt;
     This is a primitive example of using the Arduino Uno w/Ethernet Shield&lt;br /&gt;
     with outputs controlled and monitored through a TCP connection.&lt;br /&gt;
     &lt;br /&gt;
     Reading an output&amp;#039;s state:&lt;br /&gt;
       Format:    rx    (where x= output to read. 0-7 valid in this test)&lt;br /&gt;
       &lt;br /&gt;
     Writing to an output:&lt;br /&gt;
       Format:    wx:y  (where x = output to write to. 0-7 valid in this test)&lt;br /&gt;
                        (y = boolian state to write. (0 or 1))  &lt;br /&gt;
     &lt;br /&gt;
     Output 0 = pin 2, Output 1 = pin 3, etc. &lt;br /&gt;
     Only 8 contiguous outputs were available for this test, hence only 8 addressed.&lt;br /&gt;
     &lt;br /&gt;
     Posted in the Arduino Forums to assist those who like me needed to see&lt;br /&gt;
     how it was done!&lt;br /&gt;
    &lt;br /&gt;
 */&lt;br /&gt;
 &lt;br /&gt;
 #include &amp;lt;SPI.h&amp;gt;&lt;br /&gt;
 #include &amp;lt;Ethernet.h&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
 // Set values below to match your network needs:&lt;br /&gt;
 byte mac[] = {0x54, 0x52, 0x49, 0x41, 0x44, 0x00};   // MAC Address&lt;br /&gt;
 byte ip[] = {10, 0, 0, 47};                          // Network Address&lt;br /&gt;
 byte gateway[] = {10, 0, 0, 1};                      // Gateway Address&lt;br /&gt;
 byte subnet[] = {255, 255, 255, 0};                  // Subnet Mask&lt;br /&gt;
 EthernetServer server(23);                           // Set Server Port&lt;br /&gt;
 EthernetClient client;                               // Define client&lt;br /&gt;
 const int MAX_LEN = 10;                              // Maximum length of a command&lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
 void setup()&lt;br /&gt;
 {&lt;br /&gt;
   // Open serial communications and wait for port to open:&lt;br /&gt;
   Serial.begin(9600);&lt;br /&gt;
   while (!Serial) {&lt;br /&gt;
     ; // wait for serial port to connect. Needed for native USB port only&lt;br /&gt;
   }&lt;br /&gt;
   Ethernet.begin(mac, ip, gateway, subnet);          // Start the Ethernet connection&lt;br /&gt;
   server.begin();                                    // Begin acting like a server&lt;br /&gt;
   for(int x = 2; x &amp;lt; 9; x++)                         // Set up pins 2-9&lt;br /&gt;
   {                                                  // (we will call them 0-7 in our commands)&lt;br /&gt;
     pinMode(x, OUTPUT);                              // Make them all outputs&lt;br /&gt;
   }                                                  // This is the maximum we can do with an UNO&lt;br /&gt;
 }                                                    // A MEGA could easily handle more&lt;br /&gt;
 &lt;br /&gt;
 void loop()&lt;br /&gt;
 {&lt;br /&gt;
   char command[MAX_LEN];        // Set up the command buffer&lt;br /&gt;
   static int c = 0;             // Set up a counter (static so it does not get overwritten outside of this loop&lt;br /&gt;
   char inByte;                  // Set up a character buffer to grab the input&lt;br /&gt;
 &lt;br /&gt;
   client = server.available();  // Check for server availability&lt;br /&gt;
   if(client)&lt;br /&gt;
   {&lt;br /&gt;
     inByte = client.read();     // Read the character in the buffer&lt;br /&gt;
     switch (inByte)             // check for certain types&lt;br /&gt;
     {&lt;br /&gt;
     case 13:                    // carriage return: process the command&lt;br /&gt;
       command[c] = 0;           // make the current position a terminating null byte&lt;br /&gt;
       DoCommand(command);	// Process the command&lt;br /&gt;
       c = 0;                    // reset counter for next time&lt;br /&gt;
       break;                    // exit when done&lt;br /&gt;
     case 10:			// linefeed: Ignore it&lt;br /&gt;
       break;                    // and skip to the end&lt;br /&gt;
     default:                    // any character other than a CR or LF &lt;br /&gt;
       if (c &amp;lt; (MAX_LEN - 1))	// put in the command string (until it&amp;#039;s full)&lt;br /&gt;
       {&lt;br /&gt;
         command[c] = inByte;    // command concactination&lt;br /&gt;
         c++;                    // Increment our counter&lt;br /&gt;
       }&lt;br /&gt;
     }                           // end of switch&lt;br /&gt;
   }                             // end of if statement&lt;br /&gt;
 }                               // end of main loop &lt;br /&gt;
 &lt;br /&gt;
 void DoCommand(char * cmd)	// Command received: process it!&lt;br /&gt;
 {&lt;br /&gt;
   switch (cmd[0])		// Check first character of the command:&lt;br /&gt;
   {&lt;br /&gt;
   case &amp;#039;r&amp;#039;:			// r = read pin&amp;#039;s state&lt;br /&gt;
     ReadPins(cmd);		// Proceed to read the pin&lt;br /&gt;
     break;&lt;br /&gt;
   case &amp;#039;w&amp;#039;:			// w = write a state to a pin&lt;br /&gt;
     WritePins(cmd);		// Proceed to write to the pin&lt;br /&gt;
     break;&lt;br /&gt;
   default:&lt;br /&gt;
     client.println(&amp;quot;ERROR_01&amp;quot;); // ERROR_01 = bad command - only &amp;#039;r&amp;#039; and &amp;#039;w&amp;#039; are acceptable&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void ReadPins(char * cmd)	// Read a pin state&lt;br /&gt;
 {&lt;br /&gt;
   //Serial.println(&amp;quot;Reading&amp;quot;);	//debug	&lt;br /&gt;
   byte x;					&lt;br /&gt;
   x = cmd[1] - 46;		// We get an ASCII character of 0-7, which has a value in the range of 48-55&lt;br /&gt;
                                // by subtracting 46, we get a value of 2-9, which represent the pins used as outputs 0-7 for this test.&lt;br /&gt;
   if((x &amp;gt; 9) || (x &amp;lt; 2))	// If the result is outside this range, we throw an error.&lt;br /&gt;
   {&lt;br /&gt;
     client.println(&amp;quot;ERROR_02&amp;quot;); // ERROR_02 = invalid pin number&lt;br /&gt;
     return;			// and exit before we do any further harm.&lt;br /&gt;
   }&lt;br /&gt;
   client.print(&amp;quot;Output &amp;quot;);	// send out the TCP connection a message the output in question&lt;br /&gt;
   client.print(x - 2);&lt;br /&gt;
   if(digitalRead(x))&lt;br /&gt;
   {&lt;br /&gt;
     client.println(&amp;quot; is on.&amp;quot;);  // is currently on..&lt;br /&gt;
   }&lt;br /&gt;
   else&lt;br /&gt;
   {&lt;br /&gt;
     client.println(&amp;quot; is off.&amp;quot;); // or off (as the case may be)&lt;br /&gt;
   }&lt;br /&gt;
 }				// done with reading&lt;br /&gt;
 &lt;br /&gt;
 void WritePins(char * cmd)	// Write a pin state&lt;br /&gt;
 {	&lt;br /&gt;
   byte x;&lt;br /&gt;
   x = cmd[1] - 46;		// We get an ASCII character of 0-7, which is a value in the range of 48-55&lt;br /&gt;
                                // by subtracting 46, we get a value of 2-9, which represent our 0-7 outputs for this test.&lt;br /&gt;
   if((x &amp;gt; 9) || (x &amp;lt; 2))	// If the result is outside this range, we throw an error.&lt;br /&gt;
   {&lt;br /&gt;
     client.println(&amp;quot;ERROR_02&amp;quot;); // ERROR_02 = invalid pin number&lt;br /&gt;
     return;			// and exit before we do any further harm.&lt;br /&gt;
   }&lt;br /&gt;
   if(cmd[2] != &amp;#039;:&amp;#039;)		// If the third character is not a colon, we throw an error.&lt;br /&gt;
   {&lt;br /&gt;
     client.println(&amp;quot;ERROR_03&amp;quot;); // ERROR_03 = unknown separator &lt;br /&gt;
     return;			// and exit before we do any further harm.&lt;br /&gt;
   }&lt;br /&gt;
   switch (cmd[3])		// check the 4th character&lt;br /&gt;
   {&lt;br /&gt;
   case &amp;#039;0&amp;#039;:			// 0 = turn the output off&lt;br /&gt;
     digitalWrite(x, LOW);	// Write to the pin to turn it off&lt;br /&gt;
     client.print(&amp;quot;Output &amp;quot;);	// Send out the TCP connection a message the output in question&lt;br /&gt;
     client.print(x - 2);&lt;br /&gt;
     client.println(&amp;quot; is off.&amp;quot;);	// is now turned off.&lt;br /&gt;
     break;&lt;br /&gt;
   case &amp;#039;1&amp;#039;:			// 1 = turn the output on&lt;br /&gt;
     digitalWrite(x, HIGH);	// Write to the pin to turn it on&lt;br /&gt;
     client.print(&amp;quot;Output &amp;quot;);	// Send out the TCP connection a message the output in question&lt;br /&gt;
     client.print(x - 2);&lt;br /&gt;
     client.println(&amp;quot; is on.&amp;quot;);	// is now turned on.&lt;br /&gt;
     break;&lt;br /&gt;
   default:&lt;br /&gt;
     client.println(&amp;quot;ERROR_04&amp;quot;);	// ERROR_04 = Only Boolean states allowed in this test.&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;
* http://forum.arduino.cc/index.php?topic=123756.0&lt;/div&gt;</summary>
		<author><name>Onnowpurbo</name></author>
	</entry>
</feed>