outputCurrent()

[Analog I/O]
float outputCurrent(unsigned short pin);

Description

Reads the current value from the specified output pin.

Parameters

pin: the Custom Element pin.

Returns

A float value representing the current value in A.

Example Code

The code reads the current value from the pin 3 and converts the value to a voltage for the analogWrite() function.

void setup() {
    pinLabel(3, "OUT");   // sets the pin 3 label to "OUT"
    pinMode(3, OUTPUT);   // sets the digital pin 3 as output
    pinLabel(2, "IN");    // sets the pin 2 label to "IN"
    pinMode(2, INPUT);    // sets the digital pin 2 as input
}

void loop() {
    float current = outputCurrent(3);  // reads the current value from the pin 3
    float voltage = current * 10;      // converts the current value to a voltage
    analogWrite(2, voltage);           // sets the voltage obtained to the pin 2
}

Notes and Warnings

The outputCurrent() function can be used only with the pins defined as outputs.