using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;
namespace LEDS
{
public class Program
{
static OutputPort data = new OutputPort(Pins.GPIO_PIN_D2, false);
static OutputPort clock = new OutputPort(Pins.GPIO_PIN_D3, false);
static OutputPort latch = new OutputPort(Pins.GPIO_PIN_D4, false);
public static void Main()
{
int Retardo = 50;
int[] arregloLEDs = {1,2,4,8,16,32};
while (true)
{
for (int i = 0; i < 6; i++)
{
updateLEDs(arregloLEDs[i]);
Thread.Sleep(Retardo);
}
for (int i = 5; i > 0; i--)
{
updateLEDs(arregloLEDs[i]);
Thread.Sleep(Retardo);
}
}
}
static void updateLEDs(int value)
{
latch.Write(false);
for (int i = 0; i < 8; i++)
{
int bit = value & 0x80;
value = value << 1;
Debug.Print(bit.ToString());
if (bit == 128)
{
data.Write(true);
}
else
{
data.Write(false);
}
clock.Write(true);
Thread.Sleep(1);
clock.Write(false);
}
latch.Write(true);
}
}
}