Arduino Pin Library v4.2.2
An easy to use Arduino library for fast and simultaneous operations on Arduino I/O pins.
Loading...
Searching...
No Matches
Pin-Group.ino
Author
Alec Fenichel
#include <Pin.h> // Include Pin Library
#include <PinGroup.h> // Include Pin Library with support for simultaneous operations
Pin myPins[] = {Pin(2),Pin(3),Pin(5)}; // Create array of Pin objects for digital pins labelled 2,3,5 on the Arduino Uno
// The Pins used in this array must use the same DDR, PORT, and PIN registers
// Look at the Arduino documentation for your board to determine what registers each pin uses
PinGroup myPinGroup = PinGroup(myPins); // Create a Pin Group
void setup() {
Serial.begin(9600); // Start serial communication at 9600 baud
// Check to ensure all Pins in the Pin Group use the same registers
if(myPinGroup.isValid()) {
Serial.println("Pin Group is valid.");
} else {
Serial.println("Pin Group is not valid!");
while(1) {} // Infinite loop
}
myPinGroup.setOutput(); // Simultaneously set all Pins in the Pin Group to output
// Set the Pins in the Pin Group output to different values
myPins[0].setLow();
myPins[1].setHigh();
myPins[2].setLow();
}
void loop() {
myPinGroup.toggleState(); // Simultaneously set each Pin in Pin Group to its opposite state
delay(200); // Wait 200 milliseconds
}
Fast operations on Arduino I/O pins.
Simultaneous operations on Arduino I/O pins.
Class for simultaneous operations on Arduino I/O pins.
Definition PinGroup.h:18
void toggleState()
Toggle the pin state (HIGH -> LOW, LOW -> HIGH)
Definition PinGroup.h:380
void setOutput()
Set the pin mode to output.
Definition PinGroup.h:318
bool isValid()
Check the group to ensure all pins use the same registers.
Definition PinGroup.h:205
Class for fast operations on Arduino I/O pins.
Definition Pin.h:40
void setHigh()
Set the pin output to HIGH.
Definition Pin.h:349
void setLow()
Set the pin output to LOW.
Definition Pin.h:359