Interrupt Inputs Ardbox / MDuino

Interrupt Inputs Ardbox / MDuino

This post shows how to use the interrup inputs that  Industrial Shields PLCs have available. For information and description on what are interrupt inputs and how these work see this link. The interrupt inputs for Industrial Shields PLCs are listed in the pinout section of the datasheet. 

 

In this example the interrupt input I0.0  is used to caught  the pulse of an encoder (for proper connection and wiring  check this post). Every time that interrupt I00 a RISING edge, the ‘encoder’ function will be triggered and count value increased by one unit. The  count value is printed on the serial monitor.

int I00 = 2; // Ardbox Analog I0.0 interrupt input. This pin will vary depending on the interrupt input or the Industrial Shields PLC.
int count=0;

void setup() {
    pinMode(pin, OUTPUT);
    attachInterrupt(digitalPinToInterrupt(I00),encoder, RISING);

Serial.begin(9600);
}

void loop() {
    Serial.println (count);
}

void encoder() {
    count=count+1;
}

The triggering event of the interrupt function can be configured as RISING, FALLING, LOW or CHANGE (see link).

 

Comments are closed.