This circuit is very straight forward, it uses a 4N35M octocoupler, an LED and 2 resistors. There is a 1k resistor between the digital out of the netduino and pin 1 on the octo and another to match the LED. I am using a 12 volt 1 amp power supply in this example.
using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;
namespace CIRC_08
{
public class Program
{
static PWM pwm = new PWM(Pins.GPIO_PIN_D5);
public static void Main()
{
while (true)
{
for (int sensorValue = 1; sensorValue < 101; sensorValue++)
{
Debug.Print(sensorValue.ToString());
pwm.SetDutyCycle((uint)sensorValue);
Thread.Sleep(100);
}
for (int sensorValue = 100; sensorValue > 2; sensorValue--)
{
Debug.Print(sensorValue.ToString());
pwm.SetDutyCycle((uint)sensorValue);
Thread.Sleep(100);
}
pwm.SetDutyCycle(0);
Thread.Sleep(10000);
}
}
}
}