Crea sito

remote digital IO from bash script



This example was realized using the AVIL shell sketch and uncommenting the the directive #define ETH_IO in compopt.h (see Configurations).
The purpose of this example is to show how to remotely control Arduino's digital I/O from your PC (linux or windows using cgwin ).

As firs step I created this bash script ./remoteIO.sh (remember to set it as executable to run it!).
Open it with a text editor to configure ip address and port of your arduino:

As second step connect a button on pin 6 and a led on pin 7 (like this ... just pay attention at the pins number!)

The script define some functions to easily handle Arduino's digital I/O from a bash script (you can reuse the in your scripts!)
These functions sends the commands you can manually insert via telnet using netcat

Using these functions becomes easy to write an infinite loop that manage the digital I/O of a remote Arduino running the AVIL shell sketch:

Finally we can run our script from a terminal:

In this example we just print some output and turn on a led when a digital input is high, but obiouvsly you can modify the script to perfom more complex tasks on your PC depending on digital signals from the "real world"!