Arduino Playground is read-only starting December 31st, 2018. For more info please look at this Forum Post

Utility Library for Arduino
Author:  Alexander Brevig
Contact: alexanderbrevig@gmail.com


Navigation


Current version

1.0 2009-06-17: Initial Release


History

1.0 2009-06-17: Initial Release


Description

Utility is a library for the Arduino.

See the function list for details.


Download, install and import

Download here: Attach:Utility.zip

Put the Utility folder in "hardware\libraries\".
In the Arduino IDE, create a new sketch (or open one) and select from the menubar "Sketch->Import Library-> Utility".
Once the library is imported, an '#include < Utility.h>' line will appear at the top of your sketch.


Functions

foreach

This function takes an array of pins, the length of the array, target function and the modifier for the function as parameters.

foreach( array, length, function, modifier);
foreach( ledPins, 10, digitalWrite, HIGH );

sign

Determines if a value is equal,belov or above 0

int x = 2;

int signum = sign(x); //1


Example

  1. #include <Utility.h>
  2.  
  3. const byte NUMBER_OF_PINS = 4;
  4. byte ledPin[NUMBER_OF_PINS] = {10,11,12,13};
  5.  
  6. void setup(){
  7.   foreach(ledPin, NUMBER_OF_PINS, pinMode, OUTPUT); //set all pins as OUTPUT
  8. }
  9.  
  10. void loop(){
  11.   foreach(ledPin, NUMBER_OF_PINS, digitalWrite, HIGH); //set all pins HIGH
  12.   delay(1000);
  13.  
  14.   foreach(ledPin, NUMBER_OF_PINS, digitalWrite, LOW); //set all pins LOW
  15.   delay(1000);
  16.  
  17.   //manipulate pins from index 1 to index 3, inclusive
  18.   foreach(ledPin, 1, 3, digitalWrite, HIGH);//set pin 11,12 and 13 HIGH
  19.   delay(500);
  20.  
  21.   //manipulate pins from index 1 to index 2, inclusive
  22.   foreach(ledPin, 1, 2, digitalWrite, LOW);//set pin 11 and 12 LOW
  23.   delay(500);
  24. }


FAQ

//contact me


Information about this page

Part of AlphaBeta Libraries.
Last Modified: June 17, 2009, at 05:09 PM
By: AlphaBeta