Hi, i'm working on a project where i need to control a step motor by serial monitor,
what i've done so far doesn't seen to work, the stepper only move a number of steps with
one digit number (0 - 9), and if i try to use more than one, the program just sums all digits, for example, if you type 12, it will move 3 steps.
Also, i can't use negative numbers apparently.
Please help!
#include <Stepper.h>
#include <stdlib.h>
#define STEPS 200
Stepper motor(STEPS, 8, 9, 10, 11);
int i=0, g;
char ascii[10];
void setup() {
Serial.begin(9600);
motor.setSpeed(1);
}
void loop() {
if(Serial.available() > 0){
for(i=0;i<10;i++){
ascii*=Serial.read();*
if((ascii!='-')&&(ascii!='.')&&(ascii!='0')&&(ascii!='1')&&(ascii!='2')&&(ascii!='3')&&(ascii!='4')&&(ascii!='5')&&(ascii!='6')&&(ascii!='7')&&(ascii_!='8')&&(ascii*!='9')){
ascii='\0';
}
//int g = atoi(ascii);
int g = atoi(ascii);
motor.step(g);
}
}*_