Toolbox.NETMF.Hardware.Ic74hc595


Toolbox.NETMF.Hardware.Ic74hc595(SPI_Module, LatchPin, Bytes, SpeedKHz)
Use this constructor if you want to use fast managed SPI
  • SPI_Module The SPI-module the chain is connected to
  • LatchPin The latch pin the chain is connected to
  • Bytes The amount of IC's in the chain (default: 1)
  • SpeedKHz The speed of the SPI bus (default: 1000)

Toolbox.NETMF.Hardware.Ic74hc595(ClockPin, DataPin, LatchPin, Bytes, SpeedKHz)
Use this constructor when using managed SPI is impossible for whatever reason
  • ClockPin The pin where the SPI SCLK is connected to
  • DataPin The pin where the SPI MISO is connected to
  • LatchPin The latch pin the chain is connected to
  • Bytes The amount of IC's in the chain (default: 1)
  • SpeedKHz The speed of the SPI bus (default: 1000)


Methods

  • CreateParallelOut(StartBit, BitCount, Inverted) Creates a parallel output port. Used, for example, by the Adafruit RGB LCD Shield
  • Dispose() Releases the SPI pins (when using the bitbang constructor)

Property

How to connect

Toolbox.NETMF.Hardware.Ic74hc595.png

Sample code in C#

// We got 4 74HC595's in a chain
Ic74hc595 IcChain = new Ic74hc595(SPI_Devices.SPI1, Pins.GPIO_PIN_D10, 4);

// Led loop back and forward
while (true)
{
    for (int Counter = 0; Counter < IcChain.Pins.Length; ++Counter)
    {
        IcChain.Pins[Counter].Write(true);
        Thread.Sleep(50);
        IcChain.Pins[Counter].Write(false);
    }
    for (int Counter = IcChain.Pins.Length - 1; Counter > 0; --Counter)
    {
        IcChain.Pins[Counter].Write(true);
        Thread.Sleep(50);
        IcChain.Pins[Counter].Write(false);
    }
}

Sample code in VB

' We got 4 74HC595's in a chain
Dim IcChain As Ic74hc595 = New Ic74hc595(SPI_Devices.SPI1, Pins.GPIO_PIN_D10, 4)

' Led loop back and forward
Do
    For Counter = 0 To IcChain.Pins.Length - 1
        IcChain.Pins(Counter).Write(True)
        Thread.Sleep(50)
        IcChain.Pins(Counter).Write(False)
    Next
    For Counter = IcChain.Pins.Length - 1 To 1 Step -1
        IcChain.Pins(Counter).Write(True)
        Thread.Sleep(50)
        IcChain.Pins(Counter).Write(False)
    Next
Loop

Related documents

Last edited Jan 1, 2013 at 7:08 PM by Garrcomm, version 3