Hey! I've got a question. Is it possible to convert the code into start and stop of the engine so that it accelerates when starting and slows down when stopping?
Graph:
Code:
// DEFINE PINOW //
#define dirPinA 2
#define stepPinA 3
#define dirPinB 4
#define stepPinB 5
#define dirPinC 11
#define stepPinC 12
void setup()
{
// OUTPUT PINY //
pinMode(stepPinA, OUTPUT);
pinMode(dirPinA, OUTPUT);
pinMode(stepPinB, OUTPUT);
pinMode(dirPinB, OUTPUT);
pinMode(stepPinC, OUTPUT);
pinMode(dirPinC, OUTPUT);
// KIERUNEK //
}
void loop()
{
// OPENING ROBOTIC ARM //
digitalWrite(dirPinC, HIGH);
for (int n = 0; n < 400; n++)
{
stepC();
}
///////////////
digitalWrite(dirPinA, HIGH);
for (int n = 0; n < 400; n++)
{
stepA();
}
///////////////
digitalWrite(dirPinB, HIGH);
for (int n = 0; n < 400; n++)
{
stepB();
}
delay(1000);
///////////////
// CLOSING ROBOTIC ARM //
digitalWrite(dirPinB, LOW);
for (int n = 0; n < 400; n++)
{
stepB();
}
///////////////
digitalWrite(dirPinA, LOW);
for (int n = 0; n < 400; n++)
{
stepA();
}
///////////////
digitalWrite(dirPinC, LOW);
for (int n = 0; n < 400; n++)
{
stepC();
}
delay(3000);
}
void stepA()
{
digitalWrite(stepPinA, HIGH);
delay(2);
digitalWrite(stepPinA, LOW);
delay(2);
}
void stepB()
{
digitalWrite(stepPinB, HIGH);
delay(2);
digitalWrite(stepPinB, LOW);
delay(2);
}
void stepC()
{
digitalWrite(stepPinC, HIGH);
delay(2);
digitalWrite(stepPinC, LOW);
delay(2);
}