Remarks

ULN2003
Status
Source code GitHub
NuGet package

ULN2003 is a high voltage, high current Darlington array containing seven open collector Darlington pairs. The ULN2003 is often packaged on board used to control stepper motors.

Code Example

public class MeadowApp : App<F7Micro, MeadowApp>
{
    Uln2003 stepperController;

    public MeadowApp()
    {
        stepperController = new Uln2003(
                device: Device, 
                pin1: Device.Pins.D01, 
                pin2: Device.Pins.D02, 
                pin3: Device.Pins.D03, 
                pin4: Device.Pins.D04);

        stepperController.Step(1024);

        for (int i = 0; i < 100; i++)
        {
            Console.WriteLine($"Step forward {i}");
            stepperController.Step(50);
            Thread.Sleep(10);
        }

        for (int i = 0; i < 100; i++)
        {
            Console.WriteLine($"Step backwards {i}");
            stepperController.Step(-50);
            Thread.Sleep(10);
        }
    }
}

Sample projects available on GitHub

Wiring Example

To wire a ULN2003 to your Meadow board, connect the following:

ULN2003 Meadow Pin
GND GND
VCC 3V3
INT1 D01
INT2 D02
INT3 D03
INT4 D04

It should look like the following diagram:

Characteristic Locus
Inheritance System.Object > Uln2003
Inherited Members System.Object.ToString() System.Object.Equals(System.Object) System.Object.Equals(System.Object, System.Object) System.Object.ReferenceEquals(System.Object, System.Object) System.Object.GetHashCode() System.Object.GetType() System.Object.MemberwiseClone()
Namespace Meadow.Foundation.Motors.Stepper
Assembly Uln2003.dll

Syntax

public class Uln2003

Constructors

Uln2003(IIODevice, IPin, IPin, IPin, IPin)

Initialize a Uln2003 class.

Declaration
public Uln2003(IIODevice device, IPin pin1, IPin pin2, IPin pin3, IPin pin4)

Parameters

Type Name Description
IIODevice device
IPin pin1

The GPIO pin number which corresponds pin A on ULN2003 driver board.

IPin pin2

The GPIO pin number which corresponds pin B on ULN2003 driver board.

IPin pin3

The GPIO pin number which corresponds pin C on ULN2003 driver board.

IPin pin4

The GPIO pin number which corresponds pin D on ULN2003 driver board.

Properties

Mode

Sets the stepper's mode.

Declaration
public Uln2003.StepperMode Mode { get; set; }

Property Value

Type Description
Uln2003.StepperMode

RPM

Sets the motor speed to revolutions per minute.

Declaration
public short RPM { get; set; }

Property Value

Type Description
System.Int16

Remarks

Default revolutions per minute for 28BYJ-48 is approximately 15.

Methods

Step(Int32)

Moves the motor. If the number is negative, the motor moves in the reverse direction.

Declaration
public void Step(int steps)

Parameters

Type Name Description
System.Int32 steps

Number of steps.

Stop()

Stop the motor.

Declaration
public void Stop()