Charlieplex Library for Arduino Author: Alexander Brevig Contact: alexanderbrevig@gmail.com
1.0 2009-03-12: Initial Release
1.0 2009-03-12: Initial Release
Charlieplex is a library for the Arduino.
It is created to help make readable charlieplex code. It hides the pinMode, and digitalWrite calls for the user.
You can try my Charlieplex Schematic Creator.
Download here: Attach:Charlieplex.zip
Put the Charlieplex folder in "hardware\libraries\".
In the Arduino IDE, create a new sketch (or open one) and
select from the menubar "Sketch->Import Library->Charlieplex".
Once the library is imported, an "#include Charlieplex.h" line will appear
at the top of your Sketch.
Charlieplex(byte* userPins, byte numberOfUserPins)
#define NUMBER_OF_PINS 3 byte pins[] = {11,12,13}; Charlieplex charlieplex = Charlieplex(pins,NUMBER_OF_PINS);
Instanciates a Charlieplex object that uses pins 11, 12 and 13.
You'll need to define some charliePins as well. This is the syntax:
charliePin led = { 0 , 2 }; //HIGH when current flows from 11 to 13
Sets a charliePin HIGH or LOW
Set a pin as vcc (OUTPUT:HIGH)
Set a pin as gnd (OUTPUT:LOW)
Set all pins as (INPUT)
How can I use multiple Charlieplexs?
Charlieplex is a class. Therefore to Charlieplex multiple digital pins, you must create an instance for each of them. In the example above, a Charlieplex instance (Charlieplex charlieplex) is bound to the digital pins 11, 12 and 13
#define NUMBER_OF_PINS 3 byte pins[] = {11,12,13}; Charlieplex charlieplex = Charlieplex(pins,NUMBER_OF_PINS);
To add a Charlieplex bound to digital pin 6, 7, 8 and 9, you could create the following instance charlieplex2:
#define NUMBER_OF_PINS2 4 byte pins2[] = {6,7,8,9}; Charlieplex charlieplex2 = Charlieplex(pins2,NUMBER_OF_PINS2);
And now it's just to use whatever function is wanted on both:
//update instances and possibly fire funcitons charlieplex1.clear() charlieplex2.charlieWrite(led,HIGH);
Part of AlphaBeta Libraries. | |
Last Modified: | October 26, 2015, at 07:21 PM |
By: | pert |