This project enables you to control up to four LEGO® TECHNIC™ motors with Raspberry Pi add-on board Build HAT over the web.
You can configure the project using appsettings.json:
{
"HostingSettings": {
"Port": "<WebServer Port>"
},
"MontorControlSettings": {
"BuildHatPort": "<Serial Port>", // e.g. /dev/serial0
"MotorPort": "<MotorPorts to use from Build HAT>" // PortA, PortB, PortC, PortD
}
}
To build and run the application you have to:
Run dotnet restore
then dotnet run
API Method | Body | Action |
---|---|---|
GET / | Returns 'MotorControl is running...' message | |
POST /motorcontrol/runseconds | { "MotorSpeed": <0-100>, "Seconds": <RunSeconds> } |
Running Motor in given percentage speed for given seconds and then stops |
POST /motorcontrol/speed | { "MotorSpeed": <0-100> } |
Running Motor in given percentage speed and keep running |
Build HAT Documentation Using Build HAT from .NET Python Build HAT