XY Plotter help ..

I'm planning to make a simple XY plotter first with stepper motors for a complicated project later.
The thing I'm planning to do is: Control the plotter pointer to a location as directly translated from my computer. Say I have a simple serial processing sketch that sends the mouse position(X and Y values via serial to Arduino). The Arduino reads it and gets the XY values in real time via serial. I’ve built this part.

Also just started using steppers with easy driver(Never used them before). Do not want to use any libraries like access stepper or so. As stepper control is not very complicated .
The thing I’ve learnt is:
you can change the direction by HIGH, LOW for the direction pin. And then setting the other pin as HIGH and LOW consecutively like this:

void setup() {                
  pinMode(8, OUTPUT);     
  pinMode(9, OUTPUT);
  digitalWrite(8, LOW);
  digitalWrite(9, LOW);
}

void loop() {
  digitalWrite(9, HIGH);
  delay(1);          
  digitalWrite(9, LOW); 
  delay(1);          
}

The other part I’ve solved is How to figure out which direction it should go. Which is primarily like so:

If the diff between current position and target position is negative, the motor should move backwards, other wise forwards.

The problem I’m facing now is How to make the stepper travel to a translated location using screen XY values .

Guidance is much appreciated.

sorry for the varying fonts. and the lack of paragraph breaks, my input screen is nothing like the post once I hit send.

=======================================

EasyDriver should be capitalized as it is a name of a device.

you have two pins, step and direction.

to move one way, one pin is high, to move the other way, that same pin is low.

to make a step, you just send a pulse.

destination = [currentLocation say 743 ] - [ goal = 1214 ]

to take the slow steps you are taking..
without any ramp speed or such benefit that comes with the library.

millis() = 1 milisecond
delay = i microsecond

EDITORS NOTE : the color = and the #2222222 should be ignored. they are something the forum text editor dumps into my posts. any use of the word color and brackets is added by the forum.

[color=#222222]void loop() {[/color]

if ( destination > 1 ){
   digitalWriete ( 8 HIGH)
[color=#222222] digitalWrite(9, HIGH);[/color]
[color=#222222] delay(1);          [/color]
[color=#222222] digitalWrite(9, LOW); [/color]
[color=#222222] delay(1);  [/color]
[color=#222222] currentLocation = currentLocation - 1[/color]
[color=#222222]}[/color]

if ( destination < -1 ){
   digitalWriete ( 8, LOW)
 digitalWrite(9, HIGH);
 delay(1);          
 digitalWrite(9, LOW); 
 delay(1);  
 currentLocation = currentLocation + 1
}

You need to have some sort of reference position to start off with so you stepping motor knows the absolute position not just the relative position. This is normally done with a microswitch or optical switch on each axis. The start up procedure needs to step the motors towards the switch and keep going until the switch is hit. Then your absolute position can be set, normally to 0,0 but it could be some other value.

For ideas on code see the RepRap forum and pages.

You may find something useful in these links
Stepper Motor Basics
Simple Stepper Code

...R

destination = currentLocation say 743 - goal say 1214

take the slow steps you are taking..
without any ramp speed or such benefit that comes with the library

void loop() {

if ( destination > 1 ){
  digitalWriete ( 8 HIGH)
  digitalWrite(9, HIGH)
  delay(1);
  digitalWrite(9, LOW);
  delay(1);  [/color]
  currentLocation = currentLocation - 1
}

if ( destination < -1 ){
  digitalWriete ( 8, LOW)
  digitalWrite(9, HIGH);
  delay(1);          
  digitalWrite(9, LOW);
  delay(1);  
  currentLocation = currentLocation + 1
}

Thanks Will try it soon

Grumpy_Mike:
You need to have some sort of reference position to start off with so you stepping motor knows the absolute position not just the relative position. This is normally done with a microswitch or optical switch on each axis. The start up procedure needs to step the motors towards the switch and keep going until the switch is hit. Then your absolute position can be set, normally to 0,0 but it could be some other value.

For ideas on code see the RepRap forum and pages.

I did that part already ..
Thanks though