Circular LED on Mega?

A further refinement to adapt the Circular LED to any pair of pins 2 through 7 on the Mega: Replace the constructor:

[code]CircularLED::CircularLED( int data, int clk)
{
_data= data;
_clk = clk;
pinMode(_data, OUTPUT);
pinMode(_clk, OUTPUT);
PORT_Data = portOutputRegister(digitalPinToPort(_data));
PORT_Clk = portOutputRegister(digitalPinToPort(_clk));
// Hacked for Mega!
// Mega pin to port mapping: 2-E 3-E 4-G 5-E 6-H 7-H
// 2-PE4 3-PE5 4-PG5 5-PE3 6-PH3 7-PH4
if (_data == 2 || _data == 7) {
BIT_Data = 0b00010000;
}
else if (_data == 3 || _data == 4) {
BIT_Data = 0b00100000;
}
else if (_data == 5 || _data == 6) {
BIT_Data = 0b00001000;
}

if (_clk == 2 || _clk == 7) {
BIT_Clk = 0b00010000;
}
else if (_clk == 3 || _clk == 4) {
BIT_Clk = 0b00100000;
}
else if (_clk == 5 || _clk == 6) {
BIT_Clk = 0b00001000;
}
}[/code]

You can run more than one Circular LED at a time:

CircularLED circularLED1(7,6);   // (data Port H4, clk Port H3)
CircularLED circularLED2(4,3);   // (data Port G5, clk port E5)

Also be aware if you uncomment the calls to Serial.print for debugging in CircularLED::CircularLEDWrite, the timing of the writes will be degraded so that the Circular LED will not work right, this is a feature, not a bug!