#include <AccelStepper.h>
#include <MultiStepper.h>
#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
#define TFT_DC 4
#define TFT_CS 5
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
const int Stepper1step=13;
const int Stepper1dir=12;
const int Stepper2step=11;
const int Stepper2dir=10;
const int Stepper3step=9;
const int Stepper3dir=8;
const int Stepper4step=7;
const int Stepper4dir=6;
const int PotiIN=A0;
const int PotiMax=1023;
const int PotiMin=0;
int steps=200;
//Stepper Schrittmotor1(steps,Stepper1step,Stepper1dir);
//Stepper Schrittmotor2(steps,Stepper2step,Stepper2dir);
//Stepper Schrittmotor3(steps,Stepper3step,Stepper3dir);
//Stepper Schrittmotor4(steps,Stepper4step,Stepper4dir);
AccelStepper stepper1(AccelStepper::DRIVER,Stepper1step,Stepper1dir);
AccelStepper stepper2(AccelStepper::DRIVER,Stepper2step,Stepper2dir);
AccelStepper stepper3(AccelStepper::DRIVER,Stepper3step,Stepper3dir);
AccelStepper stepper4(AccelStepper::DRIVER,Stepper4step,Stepper4dir);
MultiStepper steppers;
int potilastValue =0;
void setup() {
Serial.begin(9600);
//Schrittmotor1.setSpeed(500);
//Schrittmotor2.setSpeed(500);
//Schrittmotor3.setSpeed(500);
//Schrittmotor4.setSpeed(500);
stepper1.setMaxSpeed(1000.0);
stepper2.setMaxSpeed(1000.0);
stepper3.setMaxSpeed(1000.0);
stepper4.setMaxSpeed(1000.0);
steppers.addStepper(stepper1);
steppers.addStepper(stepper2);
steppers.addStepper(stepper3);
steppers.addStepper(stepper4);
tft.begin();
tft.setCursor(26, 120);
tft.setTextColor(ILI9341_RED);
tft.setTextSize(3);
tft.println("Hello, TFT!");
tft.setCursor(20, 160);
tft.setTextColor(ILI9341_GREEN);
tft.setTextSize(2);
tft.println("I can has colors?");
delay(100);
tft.fillScreen(ILI9341_BLACK);
potilastValue=analogRead(A0);
tft.setCursor(0,300);
tft.println("Made by Metakus");
}
void loop() {
int potiValue=analogRead(A0);
int potiValuep = map(potiValue,PotiMin,PotiMax,1,100);
stepper1.setSpeed(1000*potiValuep/100);
stepper2.setSpeed(1000*potiValuep/100);
stepper3.setSpeed(1000*potiValuep/100);
stepper4.setSpeed(1000*potiValuep/100);
stepper1.runSpeed();
stepper2.runSpeed();
stepper3.runSpeed();
stepper4.runSpeed();
if(potiValue != potilastValue)
{
tft.setCursor(0, 0);
tft.fillRect(0, 16, 200, 15, ILI9341_BLACK);
tft.setTextColor(ILI9341_WHITE); tft.setTextSize(2);
tft.println("Geschwindigkeit: ");
tft.print(potiValuep);
tft.print(" %");
potilastValue=potiValue;
delay(100);
}
}