-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added sample for BidirectionalDcMotor
- Loading branch information
Showing
3 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
Source/Meadow.Foundation.Core.Samples/Motor.BidirectionalDcMotor_Sample/MeadowApp.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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=> | ||
} |
21 changes: 21 additions & 0 deletions
21
...n.Core.Samples/Motor.BidirectionalDcMotor_Sample/Motor.BidirectionalDcMotor_Sample.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
2 changes: 2 additions & 0 deletions
2
Source/Meadow.Foundation.Core.Samples/Motor.BidirectionalDcMotor_Sample/meadow.config.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
MonoControl: | ||
Options: --jit |