stepper lib

This commit is contained in:
Kseninia Mikhaylova 2024-10-03 13:23:11 +03:00
parent f5226c3c83
commit c6c50ff882
2 changed files with 18 additions and 3 deletions

View File

@ -20,6 +20,7 @@
"/home/aarizona/.arduino15/packages/arduino/hardware/avr/1.8.6/variants/eightanaloginputs",
"/home/aarizona/.arduino15/packages/arduino/hardware/avr/1.8.6/libraries/EEPROM/src",
"/home/aarizona/.arduino15/packages/arduino/hardware/avr/1.8.6/libraries/Wire/src",
"/home/aarizona/Arduino/libraries/Stepper/src",
"/home/aarizona/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/lib/gcc/avr/7.3.0/include",
"/home/aarizona/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/lib/gcc/avr/7.3.0/include-fixed",
"/home/aarizona/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/avr/include"

View File

@ -21,16 +21,25 @@ bgp, 2023
#define STEPS_FRW 258 // шаги вперёд
#define STEPS_BKW 0 // шаги назад
#define STEPPER_SPEED 30 * 2
#define STEPPER_REV 200 * 4
#define STEPPER_DELAY 1000
// =========================================================
#include <EEPROM.h>
#include "microDS3231.h"
MicroDS3231 rtc;
#include "EncButton.h"
EncButton<EB_TICK, BTN_PIN> btn;
EncButton<EB_TICK, BTN_PIN2> btn_setup;
EncButton<EB_TICK, BUNKERPIN> term_inhib;
// EncButton<EB_TICK, TERM_COIN> term_coin_put;
#include <Stepper.h>
Stepper myStepper(STEPPER_REV, STEPPIN, DIRPIN);
int feedAmount = 1;
// https://robotchip.ru/podklyuchenie-kupyuropriemnika-cashcode-sm-k-arduino/
@ -86,6 +95,8 @@ void setup()
pinMode(RELAY, OUTPUT);
sleepTime = 60 *60 * 1000;
myStepper.setSpeed(STEPPER_SPEED);
// Debug
if (DEBUG)
{
@ -179,7 +190,6 @@ void loop()
paymentsCount--;
Serial.print("Payed: ");
Serial.print(paymentsCount);
Serial.println(" times");
}
if (btn.click())
@ -203,8 +213,12 @@ void loop()
// выдача корма
void feed()
{
digitalWrite(SLEEP, HIGH);
delayMicroseconds(STEPPER_DELAY);
for (int i = 0; i < feedAmount; i++)
oneRev();
myStepper.step(STEPPER_REV);
delayMicroseconds(STEPPER_DELAY);
// oneRev();
disableMotor();
}