mirror of
https://github.com/GyverLibs/GyverMotor2.git
synced 2026-06-05 14:47:00 +03:00
23 lines
627 B
Arduino
23 lines
627 B
Arduino
#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);
|
|
} |