Cerbuino How to acces to IO pins

I am newer on Gadgeteer and specialy on Cerbuino. I try to switch on the led1 on the board.
I have MF4.2 and last GHI SDK and drivers.

I try this to acces to the led1 :

public const Cpu.Pin LED1 = (Cpu.Pin)0x12; // PB2/BOOT1


void ProgramStarted()
{
try
{
var led1 = new OutputPort(LED1, false);
led1.Write(true);
}
catch (Exception ex)
{
Debug.Print(ex.Message);
}
}
I have this exception :
“Exception was thrown: System.Exception”

How to initialize the output to swith on the led ?
Globaly how to initialize an input, how to initialize and output on the IO pins ?
Thanks

Using code tags will make your post more readable. This can be done in two ways:[ol]
Click the “101010” icon and paste your code between the

 tags or...
Select the code within your post and click the "101010" icon.[/ol]
(Generated by QuickReply)

Please check out the tutorials here:

I am newer on Gadgeteer and specialy on Cerbuino. I try to switch on the led1 on the board.
I have MF4.2 and last GHI SDK and drivers.

I try this to acces to the led1 :

public const Cpu.Pin LED1 = (Cpu.Pin)0x12; // PB2/BOOT1
...
void ProgramStarted()
{
try
{
var led1 = new OutputPort(LED1, false);
led1.Write(true);
}
catch (Exception ex)
{
Debug.Print(ex.Message);
}
}

I have this exception :
“Exception was thrown: System.Exception”

How to initialize the output to swith on the led ?
Globaly how to initialize an input, how to initialize and output on the IO pins ?
Thanks

Since you are using Gadgeteer, all mainboards come with a function that allows you to access the on-board LED. This also reserves the pin you are using, so that may be where your exception is coming from, since you are trying to use a pin that is already reserved.

Try this code:

Mainboard.SetDebugLED(led_state);

I understand that I must use code like this

            Cpu.Pin pin = GT.Socket.GetSocket(/*number of socket that you want to use*/,
 true, null, null).CpuPins[/*pin that you want to use*/];

but this syntax is for pin on a a socket.
Cerbuino has 3 sockets.

But how to access to a pin which is not on a socket but on the left side and the right side of the Cerbuino board.
I do not use the socket.

The Cerbuino specific pins are on their way in the new SDK to be re released very soon. For right now you would need to set them manually. here is a link that gives the pin outs: Home - GHI Electronics

Near the bottom there is a pic that shows PB12, PA10, etc.

I had the same question, DaverVW had a helpful class → http://www.tinyclr.com/forum/topic?id=7263