#include <TM1637.h>
#include <AccelStepper.h>
#include <SimpleRotary.h>
int CLK = 2;
int DIO = 3;
double speedA;
int ctrA = 0;
byte lastDirA = 0;
const int maxSpeed = 6400*5;
int num3;
int num2;
int num1;
TM1637 tm(CLK, DIO);
SimpleRotary rotaryA(8,12,13);
// 8 12 13
// 8 13 12 .
// 12 8 13
// 13 8 12
// 12 13 8
// 13 12 8
void setup() {
Serial.begin(9600);
tm.init();
tm.set(3);
}
void loop() {
byte i;
i = rotaryA.rotate();
int dummySpeed = 99;
if ( i == 1 && ctrA < 101 ) {
ctrA = ctrA + 2;
speedA = map(ctrA,0,100,0,maxSpeed);
}
// if ( i == 2 && ctrA > 0) {
// ctrA = ctrA - 5;
// speedA = map(ctrA, 0,100, 0, maxSpeed);
// }
// 6400 Steps/U
// SpeedA sagt wieviele Steps pro Sekunde
double spinPerMin = (speedA / 6400) * 60;
num3 = (int(spinPerMin) / 1) % 10;
num2 = (int(spinPerMin) / 10) % 10;
num1 = (int(spinPerMin) / 100) % 10;
tm.display(0, 0);
tm.display(1, num1);
tm.display(2, num2);
tm.display(3, num3);
}