mirror of
https://github.com/GyverLibs/GyverMotor2.git
synced 2026-06-05 14:47:00 +03:00
add
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
#include <Arduino.h>
|
||||
#include <GyverMotor2.h>
|
||||
|
||||
// GyverMotor2<GM2::DIR_DIR> motor(5, 6);
|
||||
// GyverMotor2<GM2::DIR_PWM> motor(5, 6);
|
||||
GyverMotor2<GM2::DIR_PWM_INV> motor(5, 6);
|
||||
// GyverMotor2<GM2::PWM_PWM_SPEED> motor(5, 6);
|
||||
// GyverMotor2<GM2::PWM_PWM_POWER> motor(5, 6);
|
||||
// GyverMotor2<GM2::DIR_DIR_PWM> motor(5, 6, 7);
|
||||
|
||||
void setup() {
|
||||
// установка ускорения
|
||||
motor.setAccel(100);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// вызов тикера
|
||||
motor.tick();
|
||||
|
||||
// скорость будет применяться плавно
|
||||
int speed = map(analogRead(0), 0, 1023, -255, 255);
|
||||
motor.runSpeed(speed);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
#include <Arduino.h>
|
||||
#include <GyverMotor2.h>
|
||||
|
||||
// GyverMotor2<GM2::DIR_DIR> motor(5, 6);
|
||||
// GyverMotor2<GM2::DIR_PWM> motor(5, 6);
|
||||
GyverMotor2<GM2::DIR_PWM_INV> motor(5, 6);
|
||||
// GyverMotor2<GM2::PWM_PWM_SPEED> motor(5, 6);
|
||||
// GyverMotor2<GM2::PWM_PWM_POWER> motor(5, 6);
|
||||
// GyverMotor2<GM2::DIR_DIR_PWM> motor(5, 6, 7);
|
||||
|
||||
void setup() {
|
||||
// motor.setDeadtime(5);
|
||||
// motor.setMinDuty(50);
|
||||
// motor.setReverse(true);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
int speed = map(analogRead(0), 0, 1023, -255, 255);
|
||||
motor.runSpeed(speed);
|
||||
}
|
||||
Reference in New Issue
Block a user