Arduino - Output Library

When using Arduino's output pin, beginners usually run into the following troubles:

The ezOutput (easy output )library is designed to solve all of the above problems and make it easy to use for not only beginners but also experienced users. It is created by ArduioGetStarted.com.

The library can be used for LED, relay, or an..​.

Library Features

  • Support HIGH, LOW and TOGGLE
  • Support get state of output pin
  • Supports blink without delay
  • Supports blink in a period
  • Easy to use with multiple output pins
  • Support time offset in blinks multiple output pins
  • All functions are non-blocking

※ NOTE THAT:

If this library is useful for your work, you can say thanks to us by buying us a coffee: PayPal.Me/arduinogetstarted

How To Install Library

On Arduino IDE, Go to Tools Manage Libraries

Arduino add library
  • Search ezOutput, then find the output library by ArduinoGetStarted
  • Click Install button to install ezOutput library.
  • Arduino output library

Or you can download it on Github

Functions

  • ezOutput()
  • high()
  • low()
  • toggle()
  • blink()
  • getState()
  • loop()

References

ezOutput()

Description

This function creates a new instance of the ezOutput class that represents a particular output pin of your Arduino board.

Syntax

ezOutput(pin)

Parameters

pin: int - Arduino's pin.

Return

A new instance of the ezOutput class.

Example

ezOutput led(7);

high()

Description

This function sets output pin to HIGH.

Syntax

led.high();

Parameters

None

Return

None

Example

#include <ezOutput.h> // ezOutput library ezOutput led(9); // create ezOutput object that attach to pin 9 void setup() { led.high(); } void loop() { }

low()

Description

This function sets output pin to LOW.

Syntax

led.low();

Parameters

None

Return

None

Example

#include <ezOutput.h> // ezOutput library ezOutput led(9); // create ezOutput object that attach to pin 9 void setup() { led.low(); } void loop() { }

toggle()

Description

This function changes the state of output pin. If the current state is HIGH, this function changes the state to LOW, and vice versa.

Syntax

led.toggle();

Parameters

None

Return

None

Example

#include <ezOutput.h> // ezOutput library ezOutput led(9); // create ezOutput object that attach to pin 9 void setup() { } void loop() { led.toggle(); delay(1000); }

blink()

Description

This function blinks (toggles) output pin continuously with specified LOW time and HIGH time. To keep blinking, we have to call loop() function. The blinking will be disabled only if we call low(), high() or toggle() functions.

Syntax

led.blink(lowTime, highTime) led.blink(lowTime, highTime, startTime)

Parameters

lowTime: unsigned long - the time output pin is LOW in milliseconds.

highTime: unsigned long - the time output pin is HIGH in milliseconds.

startTime: unsigned long - (optional) the time output pin is delayed before blinking. This is used when we want to blink multiple output pin with delay among the pins

Return

None

Example 1

#include <ezOutput.h> // ezOutput library ezOutput led(9); // create ezOutput object that attach to pin 9; void setup() { led.blink(500, 250); // 500 milliseconds ON, 250 milliseconds OFF } void loop() { led.loop(); // MUST call the led.loop() function in loop() }

Example 2

#include <ezOutput.h> // ezOutput library ezOutput led1(7); // create ezOutput object that attach to pin 7; ezOutput led2(8); // create ezOutput object that attach to pin 8; ezOutput led3(9); // create ezOutput object that attach to pin 9; void setup() { led1.blink(500, 250); // 500 milliseconds ON, 250 milliseconds OFF. start immediately led2.blink(250, 250, 1000); // 250 milliseconds ON, 250 milliseconds OFF. start after 1000 milliseconds led2.blink(100, 100, 2000); // 100 milliseconds ON, 100 milliseconds OFF. start after 2000 milliseconds } void loop() { led1.loop(); // MUST call the led1.loop() function in loop() led2.loop(); // MUST call the led2.loop() function in loop() led3.loop(); // MUST call the led3.loop() function in loop() }

getState()

This function returns the current state of output pin.

Description

Syntax

button.getStateRaw()

Parameters

None

Return

The current state of output pin.

Example

#include <ezOutput.h> // ezOutput library ezOutput led(9); // create ezOutput object that attach to pin 9; void setup() { Serial.begin(9600); } void loop() { led.toggle(); Serial.println(led.getState()); delay(1000); }

loop()

loop()

Description

This function blinks output. It is used in combination with blink() function.

Syntax

button.loop();

Parameters

None

Return

None

Example

#include <ezOutput.h> // ezOutput library ezOutput led(9); // create ezOutput object that attach to pin 9; void setup() { led.blink(500, 250); // 500 milliseconds ON, 250 milliseconds OFF } void loop() { led.loop(); // MUST call the led.loop() function in loop() }

※ OUR MESSAGES