EnglishSvenska

This post is automatically translated to English by Google Translate.

Arduino-bibliotek för motordrivare L29x

l298n arduino library
Jag håller på att bygga om min självbalanserande robot och behövde då ett smidigt sätt att styra motordrivaren L298n. Eftersom jag styr roboten med PID-regulatorer ville jag att mitt bibliotek ska ta flyttal som både är negativa och positiva. Resultatet blev ett motordrivar-bibliotek som är väldigt enkelt att använda:

/* This example shows how to set motor speed in percentage where a negative
   value will run the motor backwards.
   This is very usuful in control applications. For example the output
   from a PID controller is most often a float and can be integrated with
   this library easily. 
*/
#include <L29x.h>
L29x motorLeft(9, 22, 23); // enable (PWM), motor pin 1, motor pin 2
L29x motorRight(8, 24, 29); // enable (PWM), motor pin 1, motor pin 2

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  motorLeft.setSpeedPercentage(-12.34);
  motorRight.setSpeedPercentage(-10);      
  delay(3000);
  motorLeft.setSpeedPercentage(100);
  motorRight.setSpeedPercentage(90);      
  delay(3000);
}
Tagged with:
Posted in Arduino, Blog
2 Comments »Arduino-bibliotek för motordrivare L29x
  1. johnny lindén says:

    har du denna sia på engelska?

    /pappa

Leave a Reply

Your email address will not be published. Required fields are marked *

*