Reads the value (either HIGH or LOW) from a specified digital pin on a remote I/O board . This function automatically sets the pinMode() of the target pin to INPUT.

NOTE: the remoteRead functions in this library can be MUCH slower than remoteWrite functions.  This is because remoteRead requires a serial handshake, which is time consuming.  Where possible, call remoteRead functions no more than 1x per second, or conceive of a system where remote changes are written.  Also,  transitions (edges) are best detected locally and then written to a remote NODE.

Compare with Arduino analogWrite()


int remoteDigitalRead(pin);


pin: the target pin number, INTEGER


Integer: 1 (HIGH) or 0 (LOW)


All examples require two NODES to operate. For simplicity, one NODE should run the following while another NODE is running the listener example.

Attach an LED to digital PIN 11 of the listener NODE. Attach a button or other digital input circuit to PIN 3 of NODE running this code.

#include <StonesThrow.h>

StonesThrow st;

#define myID 2
#define pairWithID 1

void setup(){
 st.begin(myID, pairWithID);
 pinMode(11,OUTPUT);                             //  must set pinmode for LOCAL pins


void loop(){

   int digitalValue =  st.remoteDigitalRead(3);   // read digital PIN3 on REMOTE node 

   Serial.print("digitalValue: ");

   digitalWrite(11, digitalValue);     // write scaled reading to LOCAL pin
                                                    // REMEMBER set local pinModes!