.remoteAnalogWrite()

Description

Write an analog value to a PWM pin on a remote I/O board. The function automatically sets the pinMode() of the target pin to output. The analog write value expects a value between 0 – 255.

Compare with Arduino analogWrite()

Syntax

remoteAnalogWrite(pin, value);

Parameters

pin: the target pin number, INTEGER

value: 0 (off) – 255 (on), INTEGER

Returns

none

Example:

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.


#include <StonesThrow.h>

StonesThrow st;

#define myID 2
#define pairWithID 1

void setup(){
   st.begin(myID, pairWithID);
}

void loop(){

   int analogValue = analogRead(0);            // read a local analog pin

   analogValue = map(analogValue,0,1023,0,100);  // scale reading to single BYTE

   st.remoteAnalogWrite(11, analogValue);      // write scaled reading to remote NODE

   delay(250);  // can be smaller but if erratic results emerge -- increase again

}

[index]