Skip to content

Commit

Permalink
Added sample for BidirectionalDcMotor
Browse files Browse the repository at this point in the history
  • Loading branch information
ctacke committed Aug 6, 2023
1 parent f3281f7 commit 230d3a4
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using Meadow;
using Meadow.Devices;
using Meadow.Foundation.Motors;
using Meadow.Hardware;
using System.Threading.Tasks;

namespace Motor.BidirectionalDcMotor_Sample;

public class MeadowApp : App<F7FeatherV2>
{
//<!=SNIP=>

private BidirectionalDcMotor motor;

public override Task Initialize()
{
Resolver.Log.Info("Initializing...");

IDigitalOutputPort motorA;
IDigitalOutputPort motorB;

motorA = Device.Pins.D00.CreateDigitalOutputPort(false);
motorB = Device.Pins.D01.CreateDigitalOutputPort(false);

motor = new BidirectionalDcMotor(motorA, motorB);

return Task.CompletedTask;
}

public override async Task Run()
{
Resolver.Log.Info("Test Motor...");

while (true)
{
// Motor clockwise
motor.Clockwise();
await Task.Delay(1000);

// Motor Stop
motor.Stop();
await Task.Delay(500);

// Motor counter clockwise
motor.CounterClockwise();
await Task.Delay(1000);

// Motor Stop
motor.Stop();
await Task.Delay(500);
}
}

//<!=SNOP=>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Meadow.Sdk/1.1.0">
<PropertyGroup>
<RepositoryUrl>https://github.com/WildernessLabs/Meadow.Foundation</RepositoryUrl>
<Company>Wilderness Labs, Inc</Company>
<Authors>Wilderness Labs, Inc</Authors>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<TargetFramework>netstandard2.1</TargetFramework>
<OutputType>Library</OutputType>
<AssemblyName>App</AssemblyName>
<LangVersion>10</LangVersion>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\Meadow.Core\Source\implementations\f7\Meadow.F7\Meadow.F7.csproj" />
<ProjectReference Include="..\..\Meadow.Foundation.Core\Meadow.Foundation.Core.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="meadow.config.yaml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
MonoControl:
Options: --jit

0 comments on commit 230d3a4

Please sign in to comment.