hello everybody;
i am trying to do a spin coater but i have some trouble in programming. i wrote a code but i coulnd't break the for loop.i wrote my code below.
i just want to accelaret the motor with constant accerelation until it reaches the given rpm. after reahing the 1000 rpm it needs to be stay at that constant rpm for a time period. but with this code it is reaching the maximum and i again stating with initial rpm.
can you help to fix this code ?
#include <Servo.h>//Using servo library to control ESC
Servo esc; //Creating a servo class with name as esc
void setup()
{
esc.attach(8); //Specify the esc signal pin,Here as D8
Serial.begin(9600);
}
void loop()
{
int val; //Creating a variable val
int rpm;;
rpm=1000;
val=0;
for(int x = 0 ; x <= rpm; x=x+50)
{
val= map(x, 0, 1023,1000,2000);
esc.write(val);
delay(500);
Serial.println(val);
}
}