Grove RGB LED Strip driver +netduino Problem

Hi folks,

what I am trying to do is to control an RGB LED strip via bluetooth with the netduino. So far I got the grove Bluetooth Serial shield working in just a few seconds and can control 3 Leds on the Netduino with PWM. after this good experince I liked the approach using the grove LED driver to control mutiple RGBs by just using 2 pins of the netduino (From the SDA and SCL to 6 and 7, and later on to 7 and 8). I was very happy to see that this LED strip driver follows the same API as the grove LED so I could follow this tutorial:
(note: I wanted to put in here the link but as a new user I am not allowed to. It was the Turotial by tim mattision on his blog. You can find this tutorial by google entering “How-To: Write a Netduino driver for the Grove chainable RGB LED”)

But it didn’t work. So I changed the pins on the netduino, then I thought, maybe i have clock and data wrong and I changed that, then the rgb was white, instead of red what i was sending.
I tried 5V instead of 3.3v as it was written that both are accepted. But nothing happend. After that I downloaded the driver for ardunio and rewrote it into C# but still the same problem: only some odd blinking in diferent color, which I do not send. I changed also the waiting times in the bitsending stepwise from 0 up to 20000 but still no luck.
I have also added to the ouputs 2 LEDs and slowed the tranmission so I can see what would be sended and that seemed for me ok.
I also checked the P9813 datasheet, but did not get any better idea.

Does any one have an idea or did this LED strip driven by a netduino 2 and could share me the pins he used and maybe the code that runs for him?
Which one is the correct voltage ? 3.3V or 5V?
Below please find the actual code I rewrote from the Arduino driver for the RGB Led. The stuff that is comment out is the original ardino stuff. And I replaced uint_8 with byte and uint_32 with Uint32.
The result i get with this code is a very odd sometime blinking instead of a smoth rising of each color.

thanks for the help in advance
Marco

i hade to remove the using directives because the forum recognises the microframework definitions as an webpage link that I am not allowed to post as a new member, so just imaginge, everything is fine up there :wink:

[code]using System;

namespace NDLightController2
{
public class Program
{

    static OutputPort Clk;
    static OutputPort Data;
    static OutputPort LEDOnboard;
    
    
    public static void Main()
    {
        Clk = new OutputPort(Pins.GPIO_PIN_D8, true);
        Data = new OutputPort(Pins.GPIO_PIN_D7, true);
        
        LEDOnboard = new OutputPort(Pins.ONBOARD_LED, true);
        begin();
        end();
        SetColor(255, 0, 255);

        while (true)
        {
            blink(10);
            for (byte i = 0; i<255;i++)
            {
                SetColor(i, 0, 0);
                
                Thread.Sleep(10);
                //blink(1);
            }
            blink(1);
            Thread.Sleep(1000);
            for (byte i = 0; i<255;i++)
            {
                SetColor(i, i, 0);
                //blink(1);
                Thread.Sleep(10);
            }
            blink(1);
            Thread.Sleep(1000);
            for (byte i = 0; i < 255; i++)
            {
                SetColor(i, 0, i);
                //blink(1);
                Thread.Sleep(10);
            }
            blink(1);
            Thread.Sleep(1000);

        }


    }

    static void blink(byte count)
    {
        for (byte i = 0; i < count; i++)
        {
            Thread.Sleep(5);
            LEDOnboard.Write(true);
            Thread.Sleep(5);
            LEDOnboard.Write(false);

        }
    }

static void begin()
{
Send32Zero();
}

static void end()
{
Send32Zero();
}

static void ClkRise()
{
//digitalWrite(Clkpin, LOW);
Clk.Write(false);
//delayMicroseconds(20);
Sleep(200);
//digitalWrite(Clkpin, HIGH);
Clk.Write(true);
//delayMicroseconds(20);
Sleep(200);
}

static void Send32Zero()
{
byte i;

for (i=0; i<32; i++)
{
//digitalWrite(Datapin, LOW);
Clk.Write(false);
ClkRise();
}
}

static byte TakeAntiCode(byte dat)
{
byte tmp = 0;

if ((dat & 0x80) == 0)
{
tmp |= 0x02;
}

if ((dat & 0x40) == 0)
{
tmp |= 0x01;
}

return tmp;
}

// gray data
static void DatSend(UInt32 dx)
{
byte i;
Clk.Write(false);
for (i=0; i<32; i++)
{

if ((dx & 0x80000000) != 0)
{
  //digitalWrite(Datapin, HIGH);
    Data.Write(true);
}
else
{
  //digitalWrite(Datapin, LOW);
    Data.Write(false);
}

dx <<= 1;
ClkRise();

}
}

// Set color
static void SetColor(byte Red, byte Green, byte Blue)
{
UInt32 dx = 0;

dx |= (UInt32)0x03 << 30; // highest two bits 1,flag bits
dx |= (UInt32)TakeAntiCode(Blue) << 28;
dx |= (UInt32)TakeAntiCode(Green) << 26;
dx |= (UInt32)TakeAntiCode(Red) << 24;

dx |= (UInt32)Blue << 16;
dx |= (UInt32)Green << 8;
dx |= Red;

DatSend(dx);
// Clk.Write(false);
}

private static void Sleep(int duration)
{
long Delayticks = duration;

long ticksEnd = Utility.GetMachineTime().Ticks + Delayticks;
while (Utility.GetMachineTime().Ticks < ticksEnd)
{ }

}

}

}
[/code]