Remarks
x74595 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Shift registers offer the ability to increase the number of outputs on a microcontroller by using I2C or SPI interfaces. In the case of the 74xx595 series of shift registers, the SPI interface is used to output a series of bits that are then latched to the output pins of the chip.
This class allows Meadow to control the output pins on a 74HCT595 shift register using the SPI interface.
Note that when using this chip, care should be taken to ensure that the total output load of the chip does not exceed the current and thermal dissipation properties for the specific shift register being used.
Code Example
x74595 shiftRegister;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
shiftRegister = new x74595(Device.CreateSpiBus(), Device.Pins.D00, 8);
return base.Initialize();
}
public override async Task Run()
{
shiftRegister.Clear(true);
Resolver.Log.Info("Set Pin 3 to high");
//turn on pin 3
shiftRegister.WriteToPin(shiftRegister.Pins.GP3, true);
Resolver.Log.Info("Set Pin 4 to high");
//get the port for Pin4
var port4 = shiftRegister.CreateDigitalOutputPort(shiftRegister.Pins.GP4, true, Meadow.Hardware.OutputType.OpenDrain);
Resolver.Log.Info("Toggle pin 4");
await Task.Delay(1000);
port4.State = false;
await Task.Delay(1000);
port4.State = true;
await Task.Delay(1000);
Resolver.Log.Info("Raise all pins to high");
while (true)
{
shiftRegister.Clear();
foreach (var pin in shiftRegister.Pins.AllPins)
{
shiftRegister.WriteToPin(pin, true);
await Task.Delay(50);
}
}
}
Sample project(s) available on GitHub
Wiring Example
To wire a 74HCT595 to your Meadow board, connect the following:
Characteristic | Locus |
---|---|
Inheritance | object > x74595 |
Implements | IDigitalOutputController IPinController ISpiPeripheral |
Inherited Members | object.Equals(object) object.Equals(object, object) object.GetHashCode() object.GetType() object.MemberwiseClone() object.ReferenceEquals(object, object) object.ToString() |
Namespace | Meadow.Foundation.ICs.IOExpanders |
Assembly | x74595.dll |
Syntax
public class x74595 : IDigitalOutputController, IPinController, ISpiPeripheral
Constructors
x74595(ISpiBus, IPin, int, IPin?, bool[]?)
Creates a new ShiftRegister 74595 object
Declaration
public x74595(ISpiBus spiBus, IPin pinChipSelect, int pins = 8, IPin? outputEnable = null, bool[]? initialStates = null)
Parameters
Type | Name | Description |
---|---|---|
ISpiBus | spiBus | SpiBus object |
IPin | pinChipSelect | The chip select pin |
int | pins | Number of pins in the shift register (should be a multiple of 8 pins). |
IPin | outputEnable | An optional pin connected to OE used for initializing startup state |
bool[] | initialStates | An optional list of initial states for the pins. Omitting this will initialize all pins to low. |
Remarks
x74595 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Shift registers offer the ability to increase the number of outputs on a microcontroller by using I2C or SPI interfaces. In the case of the 74xx595 series of shift registers, the SPI interface is used to output a series of bits that are then latched to the output pins of the chip.
This class allows Meadow to control the output pins on a 74HCT595 shift register using the SPI interface.
Note that when using this chip, care should be taken to ensure that the total output load of the chip does not exceed the current and thermal dissipation properties for the specific shift register being used.
Code Example
x74595 shiftRegister;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
shiftRegister = new x74595(Device.CreateSpiBus(), Device.Pins.D00, 8);
return base.Initialize();
}
public override async Task Run()
{
shiftRegister.Clear(true);
Resolver.Log.Info("Set Pin 3 to high");
//turn on pin 3
shiftRegister.WriteToPin(shiftRegister.Pins.GP3, true);
Resolver.Log.Info("Set Pin 4 to high");
//get the port for Pin4
var port4 = shiftRegister.CreateDigitalOutputPort(shiftRegister.Pins.GP4, true, Meadow.Hardware.OutputType.OpenDrain);
Resolver.Log.Info("Toggle pin 4");
await Task.Delay(1000);
port4.State = false;
await Task.Delay(1000);
port4.State = true;
await Task.Delay(1000);
Resolver.Log.Info("Raise all pins to high");
while (true)
{
shiftRegister.Clear();
foreach (var pin in shiftRegister.Pins.AllPins)
{
shiftRegister.WriteToPin(pin, true);
await Task.Delay(50);
}
}
}
Sample project(s) available on GitHub
Wiring Example
To wire a 74HCT595 to your Meadow board, connect the following:
Fields
spiComms
SPI Communication bus used to communicate with the peripheral
Declaration
protected ISpiCommunications spiComms
Field Value
Type | Description |
---|---|
ISpiCommunications |
Remarks
x74595 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Shift registers offer the ability to increase the number of outputs on a microcontroller by using I2C or SPI interfaces. In the case of the 74xx595 series of shift registers, the SPI interface is used to output a series of bits that are then latched to the output pins of the chip.
This class allows Meadow to control the output pins on a 74HCT595 shift register using the SPI interface.
Note that when using this chip, care should be taken to ensure that the total output load of the chip does not exceed the current and thermal dissipation properties for the specific shift register being used.
Code Example
x74595 shiftRegister;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
shiftRegister = new x74595(Device.CreateSpiBus(), Device.Pins.D00, 8);
return base.Initialize();
}
public override async Task Run()
{
shiftRegister.Clear(true);
Resolver.Log.Info("Set Pin 3 to high");
//turn on pin 3
shiftRegister.WriteToPin(shiftRegister.Pins.GP3, true);
Resolver.Log.Info("Set Pin 4 to high");
//get the port for Pin4
var port4 = shiftRegister.CreateDigitalOutputPort(shiftRegister.Pins.GP4, true, Meadow.Hardware.OutputType.OpenDrain);
Resolver.Log.Info("Toggle pin 4");
await Task.Delay(1000);
port4.State = false;
await Task.Delay(1000);
port4.State = true;
await Task.Delay(1000);
Resolver.Log.Info("Raise all pins to high");
while (true)
{
shiftRegister.Clear();
foreach (var pin in shiftRegister.Pins.AllPins)
{
shiftRegister.WriteToPin(pin, true);
await Task.Delay(50);
}
}
}
Sample project(s) available on GitHub
Wiring Example
To wire a 74HCT595 to your Meadow board, connect the following:
Properties
DefaultSpiBusMode
The default SPI bus mode for the device
Declaration
public SpiClockConfiguration.Mode DefaultSpiBusMode { get; }
Property Value
Type | Description |
---|---|
SpiClockConfiguration.Mode |
Remarks
x74595 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Shift registers offer the ability to increase the number of outputs on a microcontroller by using I2C or SPI interfaces. In the case of the 74xx595 series of shift registers, the SPI interface is used to output a series of bits that are then latched to the output pins of the chip.
This class allows Meadow to control the output pins on a 74HCT595 shift register using the SPI interface.
Note that when using this chip, care should be taken to ensure that the total output load of the chip does not exceed the current and thermal dissipation properties for the specific shift register being used.
Code Example
x74595 shiftRegister;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
shiftRegister = new x74595(Device.CreateSpiBus(), Device.Pins.D00, 8);
return base.Initialize();
}
public override async Task Run()
{
shiftRegister.Clear(true);
Resolver.Log.Info("Set Pin 3 to high");
//turn on pin 3
shiftRegister.WriteToPin(shiftRegister.Pins.GP3, true);
Resolver.Log.Info("Set Pin 4 to high");
//get the port for Pin4
var port4 = shiftRegister.CreateDigitalOutputPort(shiftRegister.Pins.GP4, true, Meadow.Hardware.OutputType.OpenDrain);
Resolver.Log.Info("Toggle pin 4");
await Task.Delay(1000);
port4.State = false;
await Task.Delay(1000);
port4.State = true;
await Task.Delay(1000);
Resolver.Log.Info("Raise all pins to high");
while (true)
{
shiftRegister.Clear();
foreach (var pin in shiftRegister.Pins.AllPins)
{
shiftRegister.WriteToPin(pin, true);
await Task.Delay(50);
}
}
}
Sample project(s) available on GitHub
Wiring Example
To wire a 74HCT595 to your Meadow board, connect the following:
DefaultSpiBusSpeed
The default SPI bus speed for the device
Declaration
public Frequency DefaultSpiBusSpeed { get; }
Property Value
Type | Description |
---|---|
Frequency |
Remarks
x74595 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Shift registers offer the ability to increase the number of outputs on a microcontroller by using I2C or SPI interfaces. In the case of the 74xx595 series of shift registers, the SPI interface is used to output a series of bits that are then latched to the output pins of the chip.
This class allows Meadow to control the output pins on a 74HCT595 shift register using the SPI interface.
Note that when using this chip, care should be taken to ensure that the total output load of the chip does not exceed the current and thermal dissipation properties for the specific shift register being used.
Code Example
x74595 shiftRegister;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
shiftRegister = new x74595(Device.CreateSpiBus(), Device.Pins.D00, 8);
return base.Initialize();
}
public override async Task Run()
{
shiftRegister.Clear(true);
Resolver.Log.Info("Set Pin 3 to high");
//turn on pin 3
shiftRegister.WriteToPin(shiftRegister.Pins.GP3, true);
Resolver.Log.Info("Set Pin 4 to high");
//get the port for Pin4
var port4 = shiftRegister.CreateDigitalOutputPort(shiftRegister.Pins.GP4, true, Meadow.Hardware.OutputType.OpenDrain);
Resolver.Log.Info("Toggle pin 4");
await Task.Delay(1000);
port4.State = false;
await Task.Delay(1000);
port4.State = true;
await Task.Delay(1000);
Resolver.Log.Info("Raise all pins to high");
while (true)
{
shiftRegister.Clear();
foreach (var pin in shiftRegister.Pins.AllPins)
{
shiftRegister.WriteToPin(pin, true);
await Task.Delay(50);
}
}
}
Sample project(s) available on GitHub
Wiring Example
To wire a 74HCT595 to your Meadow board, connect the following:
Pins
The pin definitions
Declaration
public x74595.PinDefinitions Pins { get; }
Property Value
Type | Description |
---|---|
x74595.PinDefinitions |
Remarks
x74595 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Shift registers offer the ability to increase the number of outputs on a microcontroller by using I2C or SPI interfaces. In the case of the 74xx595 series of shift registers, the SPI interface is used to output a series of bits that are then latched to the output pins of the chip.
This class allows Meadow to control the output pins on a 74HCT595 shift register using the SPI interface.
Note that when using this chip, care should be taken to ensure that the total output load of the chip does not exceed the current and thermal dissipation properties for the specific shift register being used.
Code Example
x74595 shiftRegister;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
shiftRegister = new x74595(Device.CreateSpiBus(), Device.Pins.D00, 8);
return base.Initialize();
}
public override async Task Run()
{
shiftRegister.Clear(true);
Resolver.Log.Info("Set Pin 3 to high");
//turn on pin 3
shiftRegister.WriteToPin(shiftRegister.Pins.GP3, true);
Resolver.Log.Info("Set Pin 4 to high");
//get the port for Pin4
var port4 = shiftRegister.CreateDigitalOutputPort(shiftRegister.Pins.GP4, true, Meadow.Hardware.OutputType.OpenDrain);
Resolver.Log.Info("Toggle pin 4");
await Task.Delay(1000);
port4.State = false;
await Task.Delay(1000);
port4.State = true;
await Task.Delay(1000);
Resolver.Log.Info("Raise all pins to high");
while (true)
{
shiftRegister.Clear();
foreach (var pin in shiftRegister.Pins.AllPins)
{
shiftRegister.WriteToPin(pin, true);
await Task.Delay(50);
}
}
}
Sample project(s) available on GitHub
Wiring Example
To wire a 74HCT595 to your Meadow board, connect the following:
SpiBusMode
The SPI bus mode for the device
Declaration
public SpiClockConfiguration.Mode SpiBusMode { get; set; }
Property Value
Type | Description |
---|---|
SpiClockConfiguration.Mode |
Remarks
x74595 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Shift registers offer the ability to increase the number of outputs on a microcontroller by using I2C or SPI interfaces. In the case of the 74xx595 series of shift registers, the SPI interface is used to output a series of bits that are then latched to the output pins of the chip.
This class allows Meadow to control the output pins on a 74HCT595 shift register using the SPI interface.
Note that when using this chip, care should be taken to ensure that the total output load of the chip does not exceed the current and thermal dissipation properties for the specific shift register being used.
Code Example
x74595 shiftRegister;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
shiftRegister = new x74595(Device.CreateSpiBus(), Device.Pins.D00, 8);
return base.Initialize();
}
public override async Task Run()
{
shiftRegister.Clear(true);
Resolver.Log.Info("Set Pin 3 to high");
//turn on pin 3
shiftRegister.WriteToPin(shiftRegister.Pins.GP3, true);
Resolver.Log.Info("Set Pin 4 to high");
//get the port for Pin4
var port4 = shiftRegister.CreateDigitalOutputPort(shiftRegister.Pins.GP4, true, Meadow.Hardware.OutputType.OpenDrain);
Resolver.Log.Info("Toggle pin 4");
await Task.Delay(1000);
port4.State = false;
await Task.Delay(1000);
port4.State = true;
await Task.Delay(1000);
Resolver.Log.Info("Raise all pins to high");
while (true)
{
shiftRegister.Clear();
foreach (var pin in shiftRegister.Pins.AllPins)
{
shiftRegister.WriteToPin(pin, true);
await Task.Delay(50);
}
}
}
Sample project(s) available on GitHub
Wiring Example
To wire a 74HCT595 to your Meadow board, connect the following:
SpiBusSpeed
The SPI bus speed for the device
Declaration
public Frequency SpiBusSpeed { get; set; }
Property Value
Type | Description |
---|---|
Frequency |
Remarks
x74595 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Shift registers offer the ability to increase the number of outputs on a microcontroller by using I2C or SPI interfaces. In the case of the 74xx595 series of shift registers, the SPI interface is used to output a series of bits that are then latched to the output pins of the chip.
This class allows Meadow to control the output pins on a 74HCT595 shift register using the SPI interface.
Note that when using this chip, care should be taken to ensure that the total output load of the chip does not exceed the current and thermal dissipation properties for the specific shift register being used.
Code Example
x74595 shiftRegister;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
shiftRegister = new x74595(Device.CreateSpiBus(), Device.Pins.D00, 8);
return base.Initialize();
}
public override async Task Run()
{
shiftRegister.Clear(true);
Resolver.Log.Info("Set Pin 3 to high");
//turn on pin 3
shiftRegister.WriteToPin(shiftRegister.Pins.GP3, true);
Resolver.Log.Info("Set Pin 4 to high");
//get the port for Pin4
var port4 = shiftRegister.CreateDigitalOutputPort(shiftRegister.Pins.GP4, true, Meadow.Hardware.OutputType.OpenDrain);
Resolver.Log.Info("Toggle pin 4");
await Task.Delay(1000);
port4.State = false;
await Task.Delay(1000);
port4.State = true;
await Task.Delay(1000);
Resolver.Log.Info("Raise all pins to high");
while (true)
{
shiftRegister.Clear();
foreach (var pin in shiftRegister.Pins.AllPins)
{
shiftRegister.WriteToPin(pin, true);
await Task.Delay(50);
}
}
}
Sample project(s) available on GitHub
Wiring Example
To wire a 74HCT595 to your Meadow board, connect the following:
Methods
Clear(bool)
Clear the shift register buffer
Declaration
public void Clear(bool update = true)
Parameters
Type | Name | Description |
---|---|---|
bool | update | If true, send changes to the shift register |
Remarks
x74595 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Shift registers offer the ability to increase the number of outputs on a microcontroller by using I2C or SPI interfaces. In the case of the 74xx595 series of shift registers, the SPI interface is used to output a series of bits that are then latched to the output pins of the chip.
This class allows Meadow to control the output pins on a 74HCT595 shift register using the SPI interface.
Note that when using this chip, care should be taken to ensure that the total output load of the chip does not exceed the current and thermal dissipation properties for the specific shift register being used.
Code Example
x74595 shiftRegister;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
shiftRegister = new x74595(Device.CreateSpiBus(), Device.Pins.D00, 8);
return base.Initialize();
}
public override async Task Run()
{
shiftRegister.Clear(true);
Resolver.Log.Info("Set Pin 3 to high");
//turn on pin 3
shiftRegister.WriteToPin(shiftRegister.Pins.GP3, true);
Resolver.Log.Info("Set Pin 4 to high");
//get the port for Pin4
var port4 = shiftRegister.CreateDigitalOutputPort(shiftRegister.Pins.GP4, true, Meadow.Hardware.OutputType.OpenDrain);
Resolver.Log.Info("Toggle pin 4");
await Task.Delay(1000);
port4.State = false;
await Task.Delay(1000);
port4.State = true;
await Task.Delay(1000);
Resolver.Log.Info("Raise all pins to high");
while (true)
{
shiftRegister.Clear();
foreach (var pin in shiftRegister.Pins.AllPins)
{
shiftRegister.WriteToPin(pin, true);
await Task.Delay(50);
}
}
}
Sample project(s) available on GitHub
Wiring Example
To wire a 74HCT595 to your Meadow board, connect the following:
CreateDigitalOutputPort(IPin, bool, OutputType)
Creates a new DigitalOutputPort using the specified pin and initial state
Declaration
public IDigitalOutputPort CreateDigitalOutputPort(IPin pin, bool initialState, OutputType outputType)
Parameters
Type | Name | Description |
---|---|---|
IPin | pin | The pin number to create the port on |
bool | initialState | Whether the pin is initially high or low |
OutputType | outputType | The port output type |
Returns
Type | Description |
---|---|
IDigitalOutputPort |
Remarks
x74595 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Shift registers offer the ability to increase the number of outputs on a microcontroller by using I2C or SPI interfaces. In the case of the 74xx595 series of shift registers, the SPI interface is used to output a series of bits that are then latched to the output pins of the chip.
This class allows Meadow to control the output pins on a 74HCT595 shift register using the SPI interface.
Note that when using this chip, care should be taken to ensure that the total output load of the chip does not exceed the current and thermal dissipation properties for the specific shift register being used.
Code Example
x74595 shiftRegister;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
shiftRegister = new x74595(Device.CreateSpiBus(), Device.Pins.D00, 8);
return base.Initialize();
}
public override async Task Run()
{
shiftRegister.Clear(true);
Resolver.Log.Info("Set Pin 3 to high");
//turn on pin 3
shiftRegister.WriteToPin(shiftRegister.Pins.GP3, true);
Resolver.Log.Info("Set Pin 4 to high");
//get the port for Pin4
var port4 = shiftRegister.CreateDigitalOutputPort(shiftRegister.Pins.GP4, true, Meadow.Hardware.OutputType.OpenDrain);
Resolver.Log.Info("Toggle pin 4");
await Task.Delay(1000);
port4.State = false;
await Task.Delay(1000);
port4.State = true;
await Task.Delay(1000);
Resolver.Log.Info("Raise all pins to high");
while (true)
{
shiftRegister.Clear();
foreach (var pin in shiftRegister.Pins.AllPins)
{
shiftRegister.WriteToPin(pin, true);
await Task.Delay(50);
}
}
}
Sample project(s) available on GitHub
Wiring Example
To wire a 74HCT595 to your Meadow board, connect the following:
GetPin(string)
Get pin from name
Declaration
public IPin GetPin(string pinName)
Parameters
Type | Name | Description |
---|---|---|
string | pinName | The pin name |
Returns
Type | Description |
---|---|
IPin | An IPin object |
Remarks
x74595 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Shift registers offer the ability to increase the number of outputs on a microcontroller by using I2C or SPI interfaces. In the case of the 74xx595 series of shift registers, the SPI interface is used to output a series of bits that are then latched to the output pins of the chip.
This class allows Meadow to control the output pins on a 74HCT595 shift register using the SPI interface.
Note that when using this chip, care should be taken to ensure that the total output load of the chip does not exceed the current and thermal dissipation properties for the specific shift register being used.
Code Example
x74595 shiftRegister;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
shiftRegister = new x74595(Device.CreateSpiBus(), Device.Pins.D00, 8);
return base.Initialize();
}
public override async Task Run()
{
shiftRegister.Clear(true);
Resolver.Log.Info("Set Pin 3 to high");
//turn on pin 3
shiftRegister.WriteToPin(shiftRegister.Pins.GP3, true);
Resolver.Log.Info("Set Pin 4 to high");
//get the port for Pin4
var port4 = shiftRegister.CreateDigitalOutputPort(shiftRegister.Pins.GP4, true, Meadow.Hardware.OutputType.OpenDrain);
Resolver.Log.Info("Toggle pin 4");
await Task.Delay(1000);
port4.State = false;
await Task.Delay(1000);
port4.State = true;
await Task.Delay(1000);
Resolver.Log.Info("Raise all pins to high");
while (true)
{
shiftRegister.Clear();
foreach (var pin in shiftRegister.Pins.AllPins)
{
shiftRegister.WriteToPin(pin, true);
await Task.Delay(50);
}
}
}
Sample project(s) available on GitHub
Wiring Example
To wire a 74HCT595 to your Meadow board, connect the following:
IsValidPin(IPin)
Checks whether or not the pin passed in exists on the chip.
Declaration
protected bool IsValidPin(IPin pin)
Parameters
Type | Name | Description |
---|---|---|
IPin | pin |
Returns
Type | Description |
---|---|
bool |
Remarks
x74595 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Shift registers offer the ability to increase the number of outputs on a microcontroller by using I2C or SPI interfaces. In the case of the 74xx595 series of shift registers, the SPI interface is used to output a series of bits that are then latched to the output pins of the chip.
This class allows Meadow to control the output pins on a 74HCT595 shift register using the SPI interface.
Note that when using this chip, care should be taken to ensure that the total output load of the chip does not exceed the current and thermal dissipation properties for the specific shift register being used.
Code Example
x74595 shiftRegister;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
shiftRegister = new x74595(Device.CreateSpiBus(), Device.Pins.D00, 8);
return base.Initialize();
}
public override async Task Run()
{
shiftRegister.Clear(true);
Resolver.Log.Info("Set Pin 3 to high");
//turn on pin 3
shiftRegister.WriteToPin(shiftRegister.Pins.GP3, true);
Resolver.Log.Info("Set Pin 4 to high");
//get the port for Pin4
var port4 = shiftRegister.CreateDigitalOutputPort(shiftRegister.Pins.GP4, true, Meadow.Hardware.OutputType.OpenDrain);
Resolver.Log.Info("Toggle pin 4");
await Task.Delay(1000);
port4.State = false;
await Task.Delay(1000);
port4.State = true;
await Task.Delay(1000);
Resolver.Log.Info("Raise all pins to high");
while (true)
{
shiftRegister.Clear();
foreach (var pin in shiftRegister.Pins.AllPins)
{
shiftRegister.WriteToPin(pin, true);
await Task.Delay(50);
}
}
}
Sample project(s) available on GitHub
Wiring Example
To wire a 74HCT595 to your Meadow board, connect the following:
WriteToPin(IPin, bool)
Sets a particular pin's value.
Declaration
public void WriteToPin(IPin pin, bool value)
Parameters
Type | Name | Description |
---|---|---|
IPin | pin | The pin to write to. |
bool | value | The value to write. True for high, false for low. |
Remarks
x74595 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Shift registers offer the ability to increase the number of outputs on a microcontroller by using I2C or SPI interfaces. In the case of the 74xx595 series of shift registers, the SPI interface is used to output a series of bits that are then latched to the output pins of the chip.
This class allows Meadow to control the output pins on a 74HCT595 shift register using the SPI interface.
Note that when using this chip, care should be taken to ensure that the total output load of the chip does not exceed the current and thermal dissipation properties for the specific shift register being used.
Code Example
x74595 shiftRegister;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
shiftRegister = new x74595(Device.CreateSpiBus(), Device.Pins.D00, 8);
return base.Initialize();
}
public override async Task Run()
{
shiftRegister.Clear(true);
Resolver.Log.Info("Set Pin 3 to high");
//turn on pin 3
shiftRegister.WriteToPin(shiftRegister.Pins.GP3, true);
Resolver.Log.Info("Set Pin 4 to high");
//get the port for Pin4
var port4 = shiftRegister.CreateDigitalOutputPort(shiftRegister.Pins.GP4, true, Meadow.Hardware.OutputType.OpenDrain);
Resolver.Log.Info("Toggle pin 4");
await Task.Delay(1000);
port4.State = false;
await Task.Delay(1000);
port4.State = true;
await Task.Delay(1000);
Resolver.Log.Info("Raise all pins to high");
while (true)
{
shiftRegister.Clear();
foreach (var pin in shiftRegister.Pins.AllPins)
{
shiftRegister.WriteToPin(pin, true);
await Task.Delay(50);
}
}
}
Sample project(s) available on GitHub
Wiring Example
To wire a 74HCT595 to your Meadow board, connect the following: