[{"data":1,"prerenderedAt":723},["ShallowReactive",2],{"/arduino":3,"/arduino-surround":712},{"id":4,"title":5,"body":6,"description":686,"extension":687,"meta":688,"navigation":705,"path":709,"seo":710,"stem":12,"__hash__":711},"content/arduino.md","Arduino Extension",{"type":7,"value":8,"toc":622},"minimark",[9,22,32,36,78,88,91,94,97,131,144,150,159,167,176,188,197,204,318,327,353,376,406,429,465,492,519,546,576,599],[10,11,15],"h1",{"id":12,"className":13},"arduino",[14],"section-heading",[16,17,21],"a",{"className":18,"href":20},[19],"section-anchor","#arduino","Arduino",[23,24,27],"h2",{"id":25,"className":26},"using",[14],[16,28,31],{"className":29,"href":30},[19],"#using","Using",[33,34,35],"p",{},"For a first use without compiling code, do the following:",[37,38,39,49,52,55,58,61,64,67,70],"ol",{},[40,41,42,48],"li",{},[16,43,47],{"href":44,"rel":45},"http://ccl.northwestern.edu/netlogo/download.shtml",[46],"nofollow","Acquire the NetLogo software",". The Arduino extension comes pre-installed with NetLogo 5.2.1 and later.",[40,50,51],{},"Acquire an Arduino board and install the arduino IDE",[40,53,54],{},"Use the Arduino IDE to edit the Sketch (if desired) and send to the board. (See elaborate comments in the sketch for recommendations about what to comment out/leave in depending on your setup & circuit on the board.)",[40,56,57],{},"Once the Arduino has the sketch loaded on it, it will run that sketch whenever it is powered on.",[40,59,60],{},"Open the test “Arduino Example” model in the NetLogo Models library (it’s in the “IABM Textbook” > “Chapter 8” folder)",[40,62,63],{},"Connect the Arduino to a USB port on the computer if it is not still connected from step 3.",[40,65,66],{},"Press OPEN to choose the port to communicate with and establish the connection.",[40,68,69],{},"Use the buttons to send byte commands; use the interface to inspect variable value(s) that your sketch is sending.",[40,71,72,73,77],{},"Note that by typing ",[74,75,76],"code",{},"arduino:primitives"," you can get a list of the available commands in the extension.",[79,80,83],"h3",{"id":81,"className":82},"notes",[14],[16,84,87],{"className":85,"href":86},[19],"#notes","Notes",[33,89,90],{},"A NetLogo model using this extension must work in conjunction with an Arduino Sketch.  These two endpoints communicate by way of an application protocol that they define.  For example, if the NetLogo model sends a byte ‘1’ over the wire this may mean something to the Arduino Sketch, which will respond accordingly.  The Arduino Sketch for its own part may send name-value pairs over the serial port, which then can be looked up asynchronously by the NetLogo model.",[33,92,93],{},"The modeler is free to build as simple or as complex an application protocol on top of this raw communication mechanism.",[33,95,96],{},"The asynchronous nature of the board-to-computer communications has one notable limitation.  If you choose to try to simulate a synchronous, BLOCKING READ communications pattern, (e.g., by sending a byte-based signal to the board, which triggers a response in a known name-value pair), then you are likely to be ‘off by one’ response.  That is, if you do the following in NetLogo code:",[98,99,100],"pre",{},[74,101,102,109,110,114,117,109,122,109,126],{},[103,104,108],"span",{"className":105},[106,107],"token","variable","arduino:write-byte"," ",[103,111,113],{"className":112},[106,107],"b",[115,116],"br",{},[103,118,121],{"className":119},[106,120],"command","show",[103,123,125],{"className":124},[106,107],"arduino:get",[103,127,130],{"className":128},[106,129],"string","\"varname\"",[33,132,133,134,137,138,140,141,143],{},"You are likely to get the value of ",[74,135,136],{},"varname"," from the PRIOR command represented by writing the byte ",[74,139,113],{},".  This is because the second line of NetLogo code will execute while the Arduino is off generating a new value for ",[74,142,136],{},".",[33,145,146,147,149],{},"There are ways of getting around this (simulating a blocking interface by polling on a value to indicate fresh “news” on ",[74,148,136],{},"). But this extension works best in settings where the Arduino Sketch is “chatty” and the NetLogo model samples this stream when it needs data.",[79,151,154],{"id":152,"className":153},"compatibility",[14],[16,155,158],{"className":156,"href":157},[19],"#compatibility","Compatibility",[33,160,161,162,166],{},"This code has been tested on Windows 7 and 10 with 32-bit NetLogo and on Mac OS X.\nYou are likely to encounter issues when running this with 64-bit NetLogo in Windows 8 or Windows 10, so if you have Windows 8 or 10, please download the ",[163,164,165],"em",{},"32-Bit"," version of NetLogo if you plan on using the Arduino extension.\nWe strive for cross-platform compatibility across Mac, Win, and Linux.\nSo if you have troubles, please let us know.",[79,168,171],{"id":169,"className":170},"questions",[14],[16,172,175],{"className":173,"href":174},[19],"#questions","Questions",[33,177,178,179,183,184,143],{},"If you run into problems or have questions about the extension, please email ",[16,180,182],{"href":181},"mailto:ccl-feedback@ccl.northwestern.edu","ccl-feedback"," or ",[16,185,187],{"href":186},"mailto:cbrady@inquirelearning.com","cbrady@inquirelearning.com",[23,189,192],{"id":190,"className":191},"primitives",[14],[16,193,196],{"className":194,"href":195},[19],"#primitives","Primitives",[33,198,199,200,143],{},"Looking for the primitive reference for the Arduino extension? You can find ",[16,201,203],{"href":202},"/arduino/dictionary","the full reference here",[205,206,210,211,216,217,222,223,216,230,222,233,216,240,222,243,216,250,222,253,216,259,222,262,216,269,222,272,216,279,222,282,216,288,222,291,216,298,222,301,216,308,222,311],"div",{"id":207,"className":208},"all",[209],"prose","\n  ",[16,212,214],{"className":213,"href":195},[74],[74,215,76],{},"\n   ",[103,218,221],{"className":219},[220],"font-bold"," · "," \n  ",[16,224,227],{"className":225,"href":226},[74],"#ports",[74,228,229],{},"arduino:ports",[103,231,221],{"className":232},[220],[16,234,237],{"className":235,"href":236},[74],"#open",[74,238,239],{},"arduino:open",[103,241,221],{"className":242},[220],[16,244,247],{"className":245,"href":246},[74],"#close",[74,248,249],{},"arduino:close",[103,251,221],{"className":252},[220],[16,254,257],{"className":255,"href":256},[74],"#get",[74,258,125],{},[103,260,221],{"className":261},[220],[16,263,266],{"className":264,"href":265},[74],"#write-string",[74,267,268],{},"arduino:write-string",[103,270,221],{"className":271},[220],[16,273,276],{"className":274,"href":275},[74],"#write-int",[74,277,278],{},"arduino:write-int",[103,280,221],{"className":281},[220],[16,283,286],{"className":284,"href":285},[74],"#write-byte",[74,287,108],{},[103,289,221],{"className":290},[220],[16,292,295],{"className":293,"href":294},[74],"#is-open",[74,296,297],{},"arduino:is-open?",[103,299,221],{"className":300},[220],[16,302,305],{"className":303,"href":304},[74],"#debug-to-arduino",[74,306,307],{},"arduino:debug-to-arduino",[103,309,221],{"className":310},[220],[16,312,315],{"className":313,"href":314},[74],"#debug-from-arduino",[74,316,317],{},"arduino:debug-from-arduino",[79,319,322],{"id":320,"className":321},"all-primitives",[14],[16,323,326],{"className":324,"href":325},[19],"#all-primitives","All Primitives",[205,328,210,331,210,337,350],{"className":329,"id":190},[330],"dict_entry",[79,332,334,335,210],{"id":333},"arduinoprimitives","\n    ",[16,336,76],{"href":195},[338,339,342],"h4",{"id":340,"className":341},"arduinoprimitives-1",[14],[16,343,334,346,210],{"className":344,"href":345},[19],"#----arduinoprimitives---1",[103,347,76],{"className":348},[349],"prim_example",[33,351,352],{},"Reports a list of primitives available in the extension, with basic hints about their syntax.",[205,354,210,357,210,362,373],{"className":355,"id":356},[330],"ports",[79,358,334,360,210],{"id":359},"arduinoports",[16,361,229],{"href":226},[338,363,366],{"id":364,"className":365},"arduinoports-1",[14],[16,367,334,370,210],{"className":368,"href":369},[19],"#----arduinoports---1",[103,371,229],{"className":372},[349],[33,374,375],{},"Reports a list of port names",[205,377,210,380,210,385,401],{"className":378,"id":379},[330],"open",[79,381,334,383,210],{"id":382},"arduinoopen",[16,384,239],{"href":236},[338,386,389],{"id":387,"className":388},"arduinoopen-port-name",[14],[16,390,334,393,210],{"className":391,"href":392},[19],"#----arduinoopen-port-name--",[103,394,396,397],{"className":395},[349],"arduino:open ",[398,399,400],"i",{},"port-name",[33,402,403,404,143],{},"Opens the port named ",[163,405,400],{},[205,407,210,410,210,415,426],{"className":408,"id":409},[330],"close",[79,411,334,413,210],{"id":412},"arduinoclose",[16,414,249],{"href":246},[338,416,419],{"id":417,"className":418},"arduinoclose-1",[14],[16,420,334,423,210],{"className":421,"href":422},[19],"#----arduinoclose---1",[103,424,249],{"className":425},[349],[33,427,428],{},"Closes the currently open port.",[205,430,210,433,210,438,453],{"className":431,"id":432},[330],"get",[79,434,334,436,210],{"id":435},"arduinoget",[16,437,125],{"href":256},[338,439,442],{"id":440,"className":441},"arduinoget-var-name",[14],[16,443,334,446,210],{"className":444,"href":445},[19],"#----arduinoget-var-name--",[103,447,449,450],{"className":448},[349],"arduino:get ",[398,451,452],{},"var-name",[33,454,455,456,458,459,461,462,464],{},"Reads and reports the value associated with ",[163,457,452],{}," on the Arduino board. If there is no value associated with ",[163,460,452],{},", returns false. Note: ",[163,463,452],{}," is case insensitive.",[205,466,210,469,210,474,489],{"className":467,"id":468},[330],"write-string",[79,470,334,472,210],{"id":471},"arduinowrite-string",[16,473,268],{"href":265},[338,475,478],{"id":476,"className":477},"arduinowrite-string-string-message",[14],[16,479,334,482,210],{"className":480,"href":481},[19],"#----arduinowrite-string-string-message--",[103,483,485,486],{"className":484},[349],"arduino:write-string ",[398,487,488],{},"string-message",[33,490,491],{},"Writes a string message to the currently open port.",[205,493,210,496,210,501,516],{"className":494,"id":495},[330],"write-int",[79,497,334,499,210],{"id":498},"arduinowrite-int",[16,500,278],{"href":275},[338,502,505],{"id":503,"className":504},"arduinowrite-int-int-message",[14],[16,506,334,509,210],{"className":507,"href":508},[19],"#----arduinowrite-int-int-message--",[103,510,512,513],{"className":511},[349],"arduino:write-int ",[398,514,515],{},"int-message",[33,517,518],{},"Writes a integer message to the currently open port.",[205,520,210,523,210,528,543],{"className":521,"id":522},[330],"write-byte",[79,524,334,526,210],{"id":525},"arduinowrite-byte",[16,527,108],{"href":285},[338,529,532],{"id":530,"className":531},"arduinowrite-byte-byte-message",[14],[16,533,334,536,210],{"className":534,"href":535},[19],"#----arduinowrite-byte-byte-message--",[103,537,539,540],{"className":538},[349],"arduino:write-byte ",[398,541,542],{},"byte-message",[33,544,545],{},"Writes a byte message to the currently open port.",[205,547,210,550,210,555,566],{"className":548,"id":549},[330],"is-open",[79,551,334,553,210],{"id":552},"arduinois-open",[16,554,297],{"href":294},[338,556,559],{"id":557,"className":558},"arduinois-open-1",[14],[16,560,334,563,210],{"className":561,"href":562},[19],"#----arduinois-open---1",[103,564,297],{"className":565},[349],[33,567,568,569,183,572,575],{},"Reports a boolean value (",[74,570,571],{},"true",[74,573,574],{},"false",") indicating if a port is open.",[205,577,210,580,210,585,596],{"className":578,"id":579},[330],"debug-to-arduino",[79,581,334,583,210],{"id":582},"arduinodebug-to-arduino",[16,584,307],{"href":304},[338,586,589],{"id":587,"className":588},"arduinodebug-to-arduino-1",[14],[16,590,334,593,210],{"className":591,"href":592},[19],"#----arduinodebug-to-arduino---1",[103,594,307],{"className":595},[349],[33,597,598],{},"Reports a list of the last messages sent from NetLogo to the Arduino, up to a maximum of 5 messages.\nEach entry in this list is a string beginning with “s:” if the message sent was a string, “i:” if the message sent was an int,\nand “b:” if the message sent was a byte.",[205,600,210,603,210,608,619],{"className":601,"id":602},[330],"debug-from-arduino",[79,604,334,606,210],{"id":605},"arduinodebug-from-arduino",[16,607,317],{"href":314},[338,609,612],{"id":610,"className":611},"arduinodebug-from-arduino-1",[14],[16,613,334,616,210],{"className":614,"href":615},[19],"#----arduinodebug-from-arduino---1",[103,617,317],{"className":618},[349],[33,620,621],{},"Reports a list of lists containing any errant messages sent from NetLogo to the Arduino, up to a maximum of 10 errant messages.\nEach sublist contains the raw message as its first element and a message describing the error as the second element.",{"title":623,"searchDepth":624,"depth":625,"links":626},"",5,3,[627,633],{"id":25,"depth":628,"text":31,"children":629},2,[630,631,632],{"id":81,"depth":625,"text":87},{"id":152,"depth":625,"text":158},{"id":169,"depth":625,"text":175},{"id":190,"depth":628,"text":196,"children":634},[635,636,641,645,650,654,659,664,669,674,678,682],{"id":320,"depth":625,"text":326},{"id":333,"depth":625,"text":637,"children":638},"\n    arduino:primitives\n  ",[639],{"id":340,"depth":640,"text":637},4,{"id":359,"depth":625,"text":642,"children":643},"\n    arduino:ports\n  ",[644],{"id":364,"depth":640,"text":642},{"id":382,"depth":625,"text":646,"children":647},"\n    arduino:open\n  ",[648],{"id":387,"depth":640,"text":649},"\n    arduino:open port-name\n  ",{"id":412,"depth":625,"text":651,"children":652},"\n    arduino:close\n  ",[653],{"id":417,"depth":640,"text":651},{"id":435,"depth":625,"text":655,"children":656},"\n    arduino:get\n  ",[657],{"id":440,"depth":640,"text":658},"\n    arduino:get var-name\n  ",{"id":471,"depth":625,"text":660,"children":661},"\n    arduino:write-string\n  ",[662],{"id":476,"depth":640,"text":663},"\n    arduino:write-string string-message\n  ",{"id":498,"depth":625,"text":665,"children":666},"\n    arduino:write-int\n  ",[667],{"id":503,"depth":640,"text":668},"\n    arduino:write-int int-message\n  ",{"id":525,"depth":625,"text":670,"children":671},"\n    arduino:write-byte\n  ",[672],{"id":530,"depth":640,"text":673},"\n    arduino:write-byte byte-message\n  ",{"id":552,"depth":625,"text":675,"children":676},"\n    arduino:is-open?\n  ",[677],{"id":557,"depth":640,"text":675},{"id":582,"depth":625,"text":679,"children":680},"\n    arduino:debug-to-arduino\n  ",[681],{"id":587,"depth":640,"text":679},{"id":605,"depth":625,"text":683,"children":684},"\n    arduino:debug-from-arduino\n  ",[685],{"id":610,"depth":640,"text":683},"Documentation for the Arduino extension.","md",{"source":689,"metadataOutputPath":690,"projectConfig":691,"language":698,"inheritFrom":706,"output":705,"version":692,"icon":707,"extensionName":708,"assetsRoot":693},"../../external/extensions/arduino/arduino.md","content/arduino.metadata.yaml",{"version":692,"projectRoot":143,"scanRoot":693,"outputRoot":694,"defaults":695,"engine":701,"partials":702,"dedupeIdenticalDiskWrites":705},"7.0.4","/home/runner/work/Helio/Helio/external/extensions/arduino","content",{"inheritFrom":696,"language":698,"output":699,"extension":687,"title":700,"version":692},[697],0,"en",false,"NetLogo User Manual","mustache",{"directoryPaths":703,"extensions":704},[143],[701,687],true,[697],"logos:arduino",{"shortName":12,"fullName":21},"/arduino",{"title":5,"description":686},"HR7g7FvZaSHEOye0Bvg4EhdUzJRzCmaWwLHNDBgr83w",[713,718],{"title":714,"path":715,"stem":716,"description":717},"NetLogo 3D","/3d","3d","NetLogo includes the NetLogo 3D application that allows you to create 3D worlds.",{"title":719,"path":720,"stem":721,"description":722},"Arduino Extension Dictionary: close","/arduino/close","arduino/close","Documentation for the close primitive.",1777657789509]