int InputTXT_Int() {
int val;
while (Serial.available() == 0) ; // Wait here until input buffer has a character
{
val = Serial.parseInt(); // returns the first valid integer point number from the Serial buffer
while (Serial.available() > 0)
{ Serial.read() ; } // clear the keyboard buffer
}
return val;
}
void setup() {
Serial.begin(9600);
pinMode(9, OUTPUT);
Serial.print("Speed Motor(1-255)=");
int a=InputTXT_Int();
Serial.println(a);
Serial.print("Time Motor On(Sec)=");
int b=InputTXT_Int();
Serial.println(b);
analogWrite(9,a);
delay(b*1000);
digitalWrite(9, LOW);
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}