NetLogo banner

Home
Download
Help
Forum
Resources
Extensions
FAQ
NetLogo Publications
Contact Us
Donate

Models:
Library
Community
Modeling Commons

Beginners Interactive NetLogo Dictionary (BIND)
NetLogo Dictionary

User Manuals:
Web
Printable
Chinese
Czech
Farsi / Persian
Japanese
Spanish

  Donate

NetLogo Models Library:
IABM Textbook/chapter 8

(back to the library)

Arduino Example

[screen shot]

Note: If you download the NetLogo application, every model in the Models Library is included.

ACKNOWLEDGMENT

This model is from Chapter Eight of the book "Introduction to Agent-Based Modeling: Modeling Natural, Social and Engineered Complex Systems with NetLogo", by Uri Wilensky & William Rand.

  • Wilensky, U. & Rand, W. (2015). Introduction to Agent-Based Modeling: Modeling Natural, Social and Engineered Complex Systems with NetLogo. Cambridge, MA. MIT Press.

This model is in the IABM Textbook folder of the NetLogo Models Library. The model, as well as any updates to the model, can also be found on the textbook website: http://www.intro-to-abm.com/.

UPDATES TO THE MODEL SINCE TEXTBOOK PUBLICATION

The example described in the textbook only demonstrated communications from NetLogo to the Arduino. The current example shows both directions of communications flow.

WHAT IS IT?

This model should give a sense for the process of controlling an Arduino board with NetLogo. It demonstrates how to read numbers from the Arduino board and how to use NetLogo to turn the Arduino's onboard LED on or off. The LED is located next to pin 13 and connected to that pin.

HOW IT WORKS

The Arduino requires a custom program, or “sketch,” to run on the board for every new situation. The sketch required by this example is included in an arduino-example-sketch subfolder under the same folder of the NetLogo model library. The sketch file itself is named arduino-example-sketch.ino.

To compile your sketch file and upload it to your Arduino board, you will need to download and install the Arduino Software IDE, available from https://www.arduino.cc/en/software. You can learn how to use it by following the guide available at https://www.arduino.cc/en/Guide/HomePage.

HOW TO USE IT

Once you have sent the sketch file to your Arduino board, it should be ready to receive signals from NetLogo automatically whenever it gets plugged in.

Press the SETUP button to establish the connection between NetLogo and the Arduino. If it works, the CONNECTION TO ARDUINO ESTABLISHED? monitor should show TRUE instead of FALSE.

Once you have a connection, simply press the ON button to turn the LED on (it will stay on if it is already on) and the OFF button to turn it off (it will stay off if it is already off).

The R and C monitors demonstrate how NetLogo can read numbers generated by the Arduino board. R will be a random number between 0 and 10, while C will count from 1 to 100 and then repeat.

EXTENDING THE MODEL

This model provides you with a setup procedure that you can use to initiate the communication with your Arduino, and a simple way to turn its built-in LED on and off, but this is only the beginning. Many different kinds of Arduino sensors can be obtained at a low cost from several manufacturers: find one that you like and experiment with it!

NETLOGO FEATURES

This model uses the Arduino extension.

RELATED MODELS

The GoGoMonitor and GoGoMonitorSimple models, in the Code Examples section of the library, are somewhat related to the present model, as they show how to use NetLogo to control a GoGo board (a device similar to an Arduino).

CREDITS AND REFERENCES

(a reference to the model's URL on the web if it has one, as well as any other necessary credits, citations, and links)

HOW TO CITE

This model is part of the textbook, “Introduction to Agent-Based Modeling: Modeling Natural, Social and Engineered Complex Systems with NetLogo.”

If you mention this model or the NetLogo software in a publication, we ask that you include the citations below.

For the model itself:

Please cite the NetLogo software as:

Please cite the textbook as:

  • Wilensky, U. & Rand, W. (2015). Introduction to Agent-Based Modeling: Modeling Natural, Social and Engineered Complex Systems with NetLogo. Cambridge, MA. MIT Press.

COPYRIGHT AND LICENSE

Copyright 2015 Uri Wilensky.

CC BY-NC-SA 3.0

This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License. To view a copy of this license, visit https://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.

Commercial licenses are also available. To inquire about commercial licenses, please contact Uri Wilensky at uri@northwestern.edu.

(back to the NetLogo Models Library)