andrealombardo / l298n Goto Github PK
View Code? Open in Web Editor NEWAn easy to use Arduino library to control DC motors with an L298N module
License: GNU Affero General Public License v3.0
An easy to use Arduino library to control DC motors with an L298N module
License: GNU Affero General Public License v3.0
Arduino: 1.8.13 (Mac OS X), Board: "P1AM-100"
/Users/erikolson/Documents/Arduino/libraries/L298N/src/L298NX2.cpp: In member function 'void L298NX2::run(uint8_t)':
/Users/erikolson/Documents/Arduino/libraries/L298N/src/L298NX2.cpp:260:24: error: invalid conversion from 'uint8_t {aka unsigned char}' to 'L298N::Direction' [-fpermissive]
_motorA.run(direction);
^
In file included from /Users/erikolson/Documents/Arduino/libraries/L298N/src/L298NX2.h:5:0,
from /Users/erikolson/Documents/Arduino/libraries/L298N/src/L298NX2.cpp:7:
/Users/erikolson/Documents/Arduino/libraries/L298N/src/L298N.h:28:9: error: initializing argument 1 of 'void L298N::run(L298N::Direction)' [-fpermissive]
void run(L298N::Direction direction);
^
/Users/erikolson/Documents/Arduino/libraries/L298N/src/L298NX2.cpp:261:24: error: invalid conversion from 'uint8_t {aka unsigned char}' to 'L298N::Direction' [-fpermissive]
_motorB.run(direction);
^
In file included from /Users/erikolson/Documents/Arduino/libraries/L298N/src/L298NX2.h:5:0,
from /Users/erikolson/Documents/Arduino/libraries/L298N/src/L298NX2.cpp:7:
/Users/erikolson/Documents/Arduino/libraries/L298N/src/L298N.h:28:9: error: initializing argument 1 of 'void L298N::run(L298N::Direction)' [-fpermissive]
void run(L298N::Direction direction);
^
exit status 1
Error compiling for board P1AM-100.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Same thing for L298NX2 variant
// With Enable pin to control speed
motor A motor B
|------------------||------------------|
L298N myMotors(EN_A, IN1_A, IN2_A, EN_B, IN1_B, IN2_B);
// Without Enable pin and jumper in place
motor A motor B
|------------||------------|
L298N myMotors(IN1_A, IN2_A, IN1_B, IN2_B);
I think you should change L298N to L298NX2 in this strings:
L298N myMotors(EN_A, IN1_A, IN2_A, EN_B, IN1_B, IN2_B);
L298N myMotors(IN1_A, IN2_A, IN1_B, IN2_B);
When using L298NX2
`void L298N::stop()
{
digitalWrite(_pinIN1, LOW);
digitalWrite(_pinIN2, LOW);
analogWrite(_pinEnable, 255);
_direction = STOP;
_isMoving = false;
}`
When using stop function,It will set speed value to 255?Is this right?
when motors run then i call stop function, why does it not stop motors immediately?
there is delay less than one second before motors stop.
how to stop the motors immediately?
I get the following warnings at compile time. The type of the argument of L298NX2::run seems wrong?
/Users/shg/Documents/Arduino/libraries/L298N/src/L298NX2.cpp: In member function 'void L298NX2::run(uint8_t)':
/Users/shg/Documents/Arduino/libraries/L298N/src/L298NX2.cpp:260:24: warning: invalid conversion from 'uint8_t {aka unsigned char}' to 'L298N::Direction' [-fpermissive]
_motorA.run(direction);
^
In file included from /Users/shg/Documents/Arduino/libraries/L298N/src/L298NX2.h:5:0,
from /Users/shg/Documents/Arduino/libraries/L298N/src/L298NX2.cpp:7:
/Users/shg/Documents/Arduino/libraries/L298N/src/L298N.h:28:9: note: initializing argument 1 of 'void L298N::run(L298N::Direction)'
void run(L298N::Direction direction);
^~~
/Users/shg/Documents/Arduino/libraries/L298N/src/L298NX2.cpp:261:24: warning: invalid conversion from 'uint8_t {aka unsigned char}' to 'L298N::Direction' [-fpermissive]
_motorB.run(direction);
^
In file included from /Users/shg/Documents/Arduino/libraries/L298N/src/L298NX2.h:5:0,
from /Users/shg/Documents/Arduino/libraries/L298N/src/L298NX2.cpp:7:
/Users/shg/Documents/Arduino/libraries/L298N/src/L298N.h:28:9: note: initializing argument 1 of 'void L298N::run(L298N::Direction)'
void run(L298N::Direction direction);
^
--- L298NX2.cpp.orig 2020-09-02 21:47:44.000000000 +0900
+++ L298NX2.cpp 2020-09-02 21:42:15.000000000 +0900
@@ -255,7 +255,7 @@
_motorB.backward();
}
-void L298NX2::run(uint8_t direction)
+void L298NX2::run(L298N::Direction direction)
{
_motorA.run(direction);
_motorB.run(direction);
--- L298NX2.h.orig 2020-09-02 21:48:02.000000000 +0900
+++ L298NX2.h 2020-09-02 21:42:33.000000000 +0900
@@ -63,7 +63,7 @@
void backward();
void backwardFor(unsigned long delay, CallBackFunction callback);
void backwardFor(unsigned long delay);
- void run(uint8_t direction);
+ void run(L298N::Direction direction);
void runFor(unsigned long delay, L298N::Direction direction);
void runFor(unsigned long delay, L298N::Direction direction, CallBackFunction callback);
void stop();
Hi there, and thanks for writing this useful library! Do you have any plans to implement the ability to set the PWM frequency, and would you be open to a PR that implements this? My L298N makes a pretty harsh whine at the frequency it's currently at.
Thanks!
Won't compile on ardinuodroid
On ESP32 boards, the command analogWrite is not defined. The library has to choose analogWrite for Arduino based boards and ledcWrite for ESP32.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.