{"id":206,"date":"2008-09-09T13:58:43","date_gmt":"2008-09-09T18:58:43","guid":{"rendered":"http:\/\/www.tigoe.net\/pcomp\/code\/?p=206"},"modified":"2008-09-09T13:58:43","modified_gmt":"2008-09-09T18:58:43","slug":"lantronix-analog-sender","status":"publish","type":"post","link":"https:\/\/www.tigoe.com\/pcomp\/code\/arduinowiring\/206\/","title":{"rendered":"Lantronix Analog Sender"},"content":{"rendered":"<p>Here&#8217;s a short Wiring\/Arduino program that waits for a connection to the microcontroller via a Lantronix device, and sends out an analog reading when it&#8217;s got a connection.<\/p>\n<p>The Lantronix device is in connectMode D4, and the TX is connected to the Arduino&#8217;s RX and vice versa.<\/p>\n<p><!--more--><\/p>\n<pre>\/*\r\n Ethernet Data reporter\r\n for use with a Lantronix Xport, Xport Direct, or other\r\n device in the same family.\r\n\r\n If a remote device connects via the Xport\r\n (in connectMode D4), the microcontroller waits for bytes.\r\n If it gets a D or N, it thinks it's disconnected.\r\n Any other byte, and it thinks it's connected.\r\n When connected, it sends out analog readings.\r\n\r\n created 9 Sep 2008\r\n by Tom Igoe\r\n\r\n *\/\r\n\r\n#define DISCONNECTED 0\r\n#define CONNECTED 1\r\n\r\nint inByte;    \/\/ for incoming bytes\r\nint status;    \/\/ whether or not you're connected\r\n\r\nvoid setup() {\r\n  Serial.begin(9600);\r\n}\r\n\r\nvoid loop() {\r\n  \/\/ read new characters into a string:\r\n  if (Serial.available()) {\r\n    inByte = Serial.read();\r\n    \/\/ if you get a D or N, disconnect.\r\n    \/\/ otherwise, you're connected:\r\n    if (inByte == 'D' || inByte == 'N') {\r\n      status = DISCONNECTED;\r\n    }\r\n    else {\r\n      status = CONNECTED;\r\n    }\r\n  }\r\n\r\n  \/\/ if connected, send out the analog value:\r\n  if (status == CONNECTED) {\r\n    Serial.print(\"Analog reading: \");\r\n    Serial.println(analogRead(0), DEC);\r\n  }\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s a short Wiring\/Arduino program that waits for a connection to the microcontroller via a Lantronix device, and sends out an analog reading when it&#8217;s got a connection. The Lantronix device is in connectMode D4, and the TX is connected to the Arduino&#8217;s RX and vice versa.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,13],"tags":[32],"class_list":["post-206","post","type-post","status-publish","format-standard","hentry","category-arduinowiring","category-Lantronix","tag-embedded-network-arduino-lantronix-xport"],"_links":{"self":[{"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/posts\/206","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/comments?post=206"}],"version-history":[{"count":1,"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/posts\/206\/revisions"}],"predecessor-version":[{"id":207,"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/posts\/206\/revisions\/207"}],"wp:attachment":[{"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/media?parent=206"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/categories?post=206"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/tags?post=206"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}