document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. using System;
  2. using System.Threading;
  3. using Microsoft.SPOT;
  4. using Microsoft.SPOT.Hardware;
  5. using SecretLabs.NETMF.Hardware;
  6. using SecretLabs.NETMF.Hardware.Netduino;
  7.  
  8. namespace LEDS
  9. {
  10.     public class Program
  11.     {
  12.  
  13.         static OutputPort data = new OutputPort(Pins.GPIO_PIN_D2, false);
  14.         static OutputPort clock = new OutputPort(Pins.GPIO_PIN_D3, false);
  15.         static OutputPort latch = new OutputPort(Pins.GPIO_PIN_D4, false);
  16.  
  17.         public static void Main()
  18.         {
  19.             int Retardo = 50;
  20.             int[] arregloLEDs = {1,2,4,8,16,32};
  21.             while (true)
  22.             {
  23.                 for (int i = 0; i < 6; i++)
  24.                 {
  25.                     updateLEDs(arregloLEDs[i]);
  26.                     Thread.Sleep(Retardo);
  27.                 }
  28.                 for (int i = 5; i > 0; i--)
  29.                 {
  30.                     updateLEDs(arregloLEDs[i]);
  31.                     Thread.Sleep(Retardo);
  32.                 }
  33.             }
  34.         }
  35.  
  36.         static void updateLEDs(int value)
  37.         {
  38.             latch.Write(false);
  39.  
  40.             for (int i = 0; i < 8; i++)
  41.             {
  42.                 int bit = value & 0x80;
  43.                 value = value << 1;
  44.                 Debug.Print(bit.ToString());
  45.                 if (bit == 128)
  46.                 {
  47.                     data.Write(true);
  48.                 }
  49.                 else
  50.                 {
  51.                     data.Write(false);
  52.                 }
  53.  
  54.                 clock.Write(true);
  55.                 Thread.Sleep(1);
  56.                 clock.Write(false);
  57.             }
  58.             latch.Write(true);
  59.         }
  60.  
  61.     }
  62. }
');