Monitoring Input Ports


Example

#include <PhpocExpansion.h>
#include <Phpoc.h>

byte spcId = 1;

ExpansionPhotoInput input0(spcId, 0);
ExpansionPhotoInput input1(spcId, 1);
ExpansionPhotoInput input2(spcId, 2);
ExpansionPhotoInput input3(spcId, 3);

void setup() {
    Serial.begin(9600);
    while(!Serial)
        ;

    Phpoc.begin(PF_LOG_SPI | PF_LOG_NET);
    Expansion.begin();

    Serial.println(input0.getPID());
    Serial.println(input0.getName());
}

void loop() {
    if(input0.isOn())
        Serial.println("Port 0: 1");
    else
        Serial.println("Port 0: 0");

    if(input1.isOn())
        Serial.println("Port 1: 1");
    else
        Serial.println("Port 1: 0");

    if(input2.isOff())
        Serial.println("Port 2: 0");
    else
        Serial.println("Port 2: 1");

    if(input3.isOff())
        Serial.println("Port 3: 0");
    else
        Serial.println("Port 3: 1");

    Serial.println();

    delay(1000);
}
Port 0: 0
Port 1: 1
Port 2: 0
Port 3: 1
...