Offline
Newbie
Karma: 0
Posts: 1
|
 |
« on: January 13, 2013, 05:45:50 pm » |
Hello to all, I am new to arduino(sorry about my English). I have working on a X-Y plotter and i have a prolem. At the bottom of the program "for" loop doesn't seem to work properly.When i gave the input "a" it works however when i gave again i doesn't work again. Have you any ideas?
#include <AccelStepper.h> #include <Stepper.h> AccelStepper stepper1 (4,2,3,4,5); AccelStepper stepper2 (4,8,9,10,11);
const int stepsPerRevolution = 200; Stepper myStepper1(stepsPerRevolution, 2,3,4,5); Stepper myStepper2(stepsPerRevolution, 8,9,10,11); char p;
void setup() { Serial.begin(9600); Serial.println("TEST"); stepper1.setMaxSpeed(200.0); stepper1.setAcceleration(200.0); stepper1.moveTo(200); stepper2.setMaxSpeed(200.0); stepper2.setAcceleration(200.0); stepper2.moveTo(200);
} void loop() { if(Serial.available()>0) { p=Serial.read();
Serial.println(p); if(p=='a'){ al();//nor(650)
} int al(){ for(int s=1; s<200; s++) { stepper1.run(); stepper2.run(); delay(1); } }
|