Arduino Pin Library  v4.2.0
An easy to use Arduino library for fast and simultaneous operations on Arduino I/O pins.
Pin-Group.ino
Go to the documentation of this file.
1 
8 #include <Pin.h> // Include Pin Library
9 #include <PinGroup.h> // Include Pin Library with support for simultaneous operations
10 
11 Pin myPins[] = {Pin(2),Pin(3),Pin(5)}; // Create array of Pin objects for digital pins labelled 2,3,5 on the Arduino Uno
12 
13 // The Pins used in this array must use the same DDR, PORT, and PIN registers
14 // Look at the Arduino documentation for your board to determine what registers each pin uses
15 PinGroup myPinGroup = PinGroup(myPins); // Create a Pin Group
16 
20 void setup() {
21  Serial.begin(9600); // Start serial communication at 9600 baud
22 
23  // Check to ensure all Pins in the Pin Group use the same registers
24  if(myPinGroup.isValid()) {
25  Serial.println("Pin Group is valid.");
26  } else {
27  Serial.println("Pin Group is not valid!");
28  while(1) {} // Infinite loop
29  }
30 
31  myPinGroup.setOutput(); // Simultaneously set all Pins in the Pin Group to output
32 
33  // Set the Pins in the Pin Group output to different values
34  myPins[0].setLow();
35  myPins[1].setHigh();
36  myPins[2].setLow();
37 }
38 
42 void loop() {
43  myPinGroup.toggleState(); // Simultaneously set each Pin in Pin Group to its opposite state
44 
45  delay(200); // Wait 200 milliseconds
46 
47 }
void setHigh()
Set the pin output to HIGH.
Definition: Pin.h:365
Class for fast operations on Arduino I/O pins.
Definition: Pin.h:39
bool isValid()
Check the group to ensure all pins use the same registers.
Definition: PinGroup.h:205
void setOutput()
Set the pin mode to output.
Definition: PinGroup.h:327
Simultaneous operations on Arduino I/O pins.
Pin myPins[]
Definition: Pin-Group.ino:11
Fast operations on Arduino I/O pins.
void setLow()
Set the pin output to LOW.
Definition: Pin.h:375
void setup()
Called at start.
Definition: Pin-Group.ino:20
PinGroup myPinGroup
Definition: Pin-Group.ino:15
void loop()
Called continously after setup.
Definition: Pin-Group.ino:42
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:394