/*#include <Button.h>
#include "Buttons.h"*/
#include "JoystickXY.h"
#include "SpeedManager.h"
#define PIN_BTN_FWD_L 32 // Кнопка вперед левый мотор
#define PIN_BTN_FWD_R 33 // Кнопка вперед правый мотор
#define PIN_BTN_BWD_L 34 // Кнопка назад левый мотор
#define PIN_BTN_BWD_R 35 // Кнопка назад правый мотор
#define VERT_PIN A0 // джойстик. пин слежения за вертикалью
#define HORZ_PIN A1 // джойстик. пин слежения за горизонталью
#define PIN_POT_PWR A5 // Потенциометр
// init
// Buttons buttons(PIN_BTN_FWD_L, PIN_BTN_FWD_R, PIN_BTN_BWD_L, PIN_BTN_BWD_R);
SpeedManager speedManager(PIN_POT_PWR);
JoystickXY joystickXY(HORZ_PIN, VERT_PIN);
void setup() {
// buttons.begin();
speedManager.begin();
joystickXY.begin();
while (!Serial) { }; // for Leos
Serial.begin(9600);
Serial.println("Init success. Go");
}
void loop() {
// put your main code here, to run repeatedly:
/*
if (buttons.getLeftSideDirection() == Buttons::Direction::Forward) {
Serial.println("Left: forward");
} else if (buttons.getLeftSideDirection() == Buttons::Direction::Backward) {
Serial.println("Left: backward");
} else {
// both LEFT buttons pressed (or both not pressed) - stop motor
// will send signal but not println in console on every tick
}
if (buttons.getRightSideDirection() == Buttons::Direction::Forward) {
Serial.println("Right: forward");
} else if (buttons.getRightSideDirection() == Buttons::Direction::Backward) {
Serial.println("Right: backward");
} else {
// both Right buttons pressed (or both not pressed) - stop motor
// will send signal but not println in console on every tick
}
*/
JoystickXY::Coords coords = joystickXY.getCoords();
Serial.print("Coord X: ");
Serial.print(coords.x);
Serial.println("");
Serial.print("Coord Y: ");
Serial.print(coords.y);
Serial.println("");
Serial.print("Speed: ");
Serial.println(speedManager.getValue());
}