Pasar librería de Arduino a AVRStudio (ATmega)

#1
desde ya gracias a todo el que me de alguna idea​
yo no uso arduino ., pero queria ver la manera de pasar esta libreria a C ., para usar en AVRstudio​
tal vez sea nesesario crear una libreria .H ., el codigo se repite despues de las primeras lineas ., o sea que el principio es nesesario ., lo que se repite sera cuestion de configurar​
gracias a todos de antemano.,​
PHP:
void setup(){  //set output pins
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
}

int tON = 2750;  //declare on time of pulse
int tOFF = 250;  //declare off time of pulse

void xplus16(){  //define function of 16 positive X steps
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
}
     
void xplus15(){ //define function of 15 positive X steps
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
}
 
void xplus14(){  //define function of 14 positive x steps
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
}

void xplus13(){  //define function of 13 positive x steps
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
}

void xplus12(){  //define function of 12 positive x steps
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
}

void xplus11(){  //define function of 11 positive x steps
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
}

void xplus10(){  //define function of 10 positive x steps
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
}

void xplus9(){  //define function of 9 positive x steps
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
}

void xplus8(){  //define function of 8 positive x steps
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
}

void xplus7(){  //define function of 7 positive x steps
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
}

void xplus6(){  //define function of 6 positive x steps
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
}

void xplus5(){  //define function of 5 positive x steps
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
}

void xplus4(){  //define function of 4 positive x steps
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
}

void xplus3(){  //define function of 3 positive x steps
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
}

void xplus2(){  //define function of 2 positive x steps
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
}

void xplus1(){  //define function of 1 positive x steps
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
}
  
void xminus16(){  //define function of 16 negative X steps
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
}   

void xminus15(){  //define function of 15 negative X steps
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
}

void xminus14(){  //define function of 14 negative X steps
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
}

void xminus13(){  //define function of 13 negative X steps
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
}

void xminus12(){  //define function of 12 negative X steps
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
}

void xminus11(){  //define function of 11 negative X steps
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
}

void xminus10(){  //define function of 10 negative X steps
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
}

void xminus9(){  //define function of 9 negative X steps
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
}

void xminus8(){  //define function of 8 negative X steps
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
}

void xminus7(){  //define function of 7 negative X steps
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
}

void xminus6(){  //define function of 6 negative X steps
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
}

void xminus5(){  //define function of 5 negative X steps
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
}

void xminus4(){  //define function of 4 negative X steps
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
}

void xminus3(){  //define function of 3 negative X steps
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
}

void xminus2(){  //define function of 2 negative X steps
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
}

void xminus1(){  //define function of 1 negative X steps
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
}
    
    
void yplus16(){
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
}

void yplus15(){
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
}
  
void yplus14(){
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
}

void yplus13(){
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
}

void yplus12(){
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
}

void yplus11(){
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
}

void yplus10(){
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
}

void yplus9(){
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
}

void yplus8(){
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
}

void yplus7(){
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
}

void yplus6(){
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
}

void yplus5(){
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
}

void yplus4(){
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
}

void yplus3(){
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
}

void yplus2(){
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
}

void yplus1(){
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
}    
    
void yminus16(){
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
}

void yminus15(){
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
}

void yminus14(){
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
}

void yminus13(){
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
}

void yminus12(){
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
}

void yminus11(){
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
}

void yminus10(){
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
}

void yminus9(){
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
}
 
void yminus8(){
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
}

void yminus7(){
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
}

void yminus6(){
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
}

void yminus5(){
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
}

void yminus4(){
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
}

void yminus3(){
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
}

void yminus2(){
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
}

void yminus1(){
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
}
     
void loop(){
  yplus4();
  xplus4();
  yplus4();
  xminus4();
  yminus4();
  xplus4();
  yminus4();
  xminus4();  
}
 
Última edición:
#2
Hola, te refieres a las funciones pinMode, digitalWrite, etc... puedes iniciar viendo el código interno en \Arduino\hardware\arduino\avr\cores\arduino, por ejemplo en wiring_digital.c

Saludos
 
#3
hola y gracias
Hola, te refieres a las funciones pinMode, digitalWrite, etc... puedes iniciar viendo el código interno en \Arduino\hardware\arduino\avr\cores\arduino, por ejemplo en wiring_digital.c

Saludos
eso a que te refieres ¿¿ se encuentra en la pagina de arduino ??? ., algo como esto
PHP:
*
  wiring_digital.c - digital input and output functions
  Part of Arduino - http://www.arduino.cc/
  Copyright (c) 2005-2006 David A. Mellis
  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.
  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.
  You should have received a copy of the GNU Lesser General
  Public License along with this library; if not, write to the
  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  Boston, MA  02111-1307  USA
  Modified 28 September 2010 by Mark Sproul
*/

#define ARDUINO_MAIN
#include "wiring_private.h"
#include "pins_arduino.h"

void pinMode(uint8_t pin, uint8_t mode)
{
	uint8_t bit = digitalPinToBitMask(pin);
	uint8_t port = digitalPinToPort(pin);
	volatile uint8_t *reg, *out;

	if (port == NOT_A_PIN) return;

	// JWS: can I let the optimizer do this?
	reg = portModeRegister(port);
	out = portOutputRegister(port);

	if (mode == INPUT) { 
		uint8_t oldSREG = SREG;
                cli();
		*reg &= ~bit;
		*out &= ~bit;
		SREG = oldSREG;
	} else if (mode == INPUT_PULLUP) {
		uint8_t oldSREG = SREG;
                cli();
		*reg &= ~bit;
		*out |= bit;
		SREG = oldSREG;
	} else {
		uint8_t oldSREG = SREG;
                cli();
		*reg |= bit;
		SREG = oldSREG;
	}
}

// Forcing this inline keeps the callers from having to push their own stuff
// on the stack. It is a good performance win and only takes 1 more byte per
// user than calling. (It will take more bytes on the 168.)
//
// But shouldn't this be moved into pinMode? Seems silly to check and do on
// each digitalread or write.
//
// Mark Sproul:
// - Removed inline. Save 170 bytes on atmega1280
// - changed to a switch statment; added 32 bytes but much easier to read and maintain.
// - Added more #ifdefs, now compiles for atmega645
//
//static inline void turnOffPWM(uint8_t timer) __attribute__ ((always_inline));
//static inline void turnOffPWM(uint8_t timer)
static void turnOffPWM(uint8_t timer)
{
	switch (timer)
	{
		#if defined(TCCR1A) && defined(COM1A1)
		case TIMER1A:   cbi(TCCR1A, COM1A1);    break;
		#endif
		#if defined(TCCR1A) && defined(COM1B1)
		case TIMER1B:   cbi(TCCR1A, COM1B1);    break;
		#endif
		#if defined(TCCR1A) && defined(COM1C1)
		case TIMER1C:   cbi(TCCR1A, COM1C1);    break;
		#endif
		
		#if defined(TCCR2) && defined(COM21)
		case  TIMER2:   cbi(TCCR2, COM21);      break;
		#endif
		
		#if defined(TCCR0A) && defined(COM0A1)
		case  TIMER0A:  cbi(TCCR0A, COM0A1);    break;
		#endif
		
		#if defined(TCCR0A) && defined(COM0B1)
		case  TIMER0B:  cbi(TCCR0A, COM0B1);    break;
		#endif
		#if defined(TCCR2A) && defined(COM2A1)
		case  TIMER2A:  cbi(TCCR2A, COM2A1);    break;
		#endif
		#if defined(TCCR2A) && defined(COM2B1)
		case  TIMER2B:  cbi(TCCR2A, COM2B1);    break;
		#endif
		
		#if defined(TCCR3A) && defined(COM3A1)
		case  TIMER3A:  cbi(TCCR3A, COM3A1);    break;
		#endif
		#if defined(TCCR3A) && defined(COM3B1)
		case  TIMER3B:  cbi(TCCR3A, COM3B1);    break;
		#endif
		#if defined(TCCR3A) && defined(COM3C1)
		case  TIMER3C:  cbi(TCCR3A, COM3C1);    break;
		#endif

		#if defined(TCCR4A) && defined(COM4A1)
		case  TIMER4A:  cbi(TCCR4A, COM4A1);    break;
		#endif					
		#if defined(TCCR4A) && defined(COM4B1)
		case  TIMER4B:  cbi(TCCR4A, COM4B1);    break;
		#endif
		#if defined(TCCR4A) && defined(COM4C1)
		case  TIMER4C:  cbi(TCCR4A, COM4C1);    break;
		#endif			
		#if defined(TCCR4C) && defined(COM4D1)
		case TIMER4D:	cbi(TCCR4C, COM4D1);	break;
		#endif			
			
		#if defined(TCCR5A)
		case  TIMER5A:  cbi(TCCR5A, COM5A1);    break;
		case  TIMER5B:  cbi(TCCR5A, COM5B1);    break;
		case  TIMER5C:  cbi(TCCR5A, COM5C1);    break;
		#endif
	}
}

void digitalWrite(uint8_t pin, uint8_t val)
{
	uint8_t timer = digitalPinToTimer(pin);
	uint8_t bit = digitalPinToBitMask(pin);
	uint8_t port = digitalPinToPort(pin);
	volatile uint8_t *out;

	if (port == NOT_A_PIN) return;

	// If the pin that support PWM output, we need to turn it off
	// before doing a digital write.
	if (timer != NOT_ON_TIMER) turnOffPWM(timer);

	out = portOutputRegister(port);

	uint8_t oldSREG = SREG;
	cli();

	if (val == LOW) {
		*out &= ~bit;
	} else {
		*out |= bit;
	}

	SREG = oldSREG;
}

int digitalRead(uint8_t pin)
{
	uint8_t timer = digitalPinToTimer(pin);
	uint8_t bit = digitalPinToBitMask(pin);
	uint8_t port = digitalPinToPort(pin);

	if (port == NOT_A_PIN) return LOW;

	// If the pin that support PWM output, we need to turn it off
	// before getting a digital reading.
	if (timer != NOT_ON_TIMER) turnOffPWM(timer);

	if (*portInputRegister(port) & bit) return HIGH;
	return LOW;
}
 
Última edición:
#5
Debería estar en la carpeta de instalación de arduino (archivos de programa si es Windows, si es en Linux yo lo tengo tirado en una carpeta cualquiera, donde descomprimí quedó).

La otra vez estaba viendo como generaba código el arduino. Me parece que lo único "extra" que tiene respecto a un proyecto con archivos .c y .h es que combina todos los "sketchs" en un solo archivo, y termina llamando al compilador de avr (avr-gcc) como siempre. Y sí, también Arduino tiene sus propias librerías (el equivalente o mejor dicho complementario al libc, para manejar I/O básico, timers, comunicación serie, etc). A ver... acá está:
https://www.arduino.cc/en/Hacking/BuildProcess

El IDE de Arduino es muuuy limitado. Para alguien acostumbrado a usar code completion, navegación de código, lista de funciones y variables en la vista de código, distintas configuración para debug y release, meter ayuda en doxygen, integrarlo con un repositorio tipo git, etc, etc; es casi como usar un editor de texto desnudo.
Pero eso en lo que se refiere a teclear código, después reconozco que está muy sencillo configurar placas, usar librerías, toda la parte de soporte de hardware me parece muy buena.

Por eso para tener lo mejor de los 2 mundos tenés plugins para Visual Studio, Eclipse, y otros IDEs más completos:
http://playground.arduino.cc/Main/DevelopmentTools
Plugin para AVR studio:
http://www.visualmicro.com/

Me fuí por las ramas... que era lo que preguntabas?, ah sí!!!, usar el código C de Arduino. Fijate bien como es el tema de las licencias, en teoría si el código de Arduino esta licenciado para uso no comercial, y vos querés usar ese código para vender millones de unidades del SyncroMaster 7000, no sería ético usar ese código.
 
Última edición:
#6
Si, Arduino tiene su Main.c dentro de este llama a setup() y loop(), de hecho la librería principal es Arduino.h, de ahí toma el resto, si importas esa librería está la posibilidad de que reconozca el código, el problema es si lo quieres importar para un chip que no está soportado por Arduino.
 
#7
hola y gracias
Debería estar en la carpeta de instalación de arduino (archivos de programa si es Windows, si es en Linux yo lo tengo tirado en una carpeta cualquiera, donde descomprimí quedó).

La otra vez estaba viendo como generaba código el arduino. Me parece que lo único "extra" que tiene respecto a un proyecto con archivos .c y .h es que combina todos los "sketchs" en un solo archivo, y termina llamando al compilador de avr (avr-gcc) como siempre. Y sí, también Arduino tiene sus propias librerías (el equivalente o mejor dicho complementario al libc, para manejar I/O básico, timers, comunicación serie, etc). A ver... acá está:
https://www.arduino.cc/en/Hacking/BuildProcess

El IDE de Arduino es muuuy limitado. Para alguien acostumbrado a usar code completion, navegación de código, lista de funciones y variables en la vista de código, distintas configuración para debug y release, meter ayuda en doxygen, integrarlo con un repositorio tipo git, etc, etc; es casi como usar un editor de texto desnudo.
Pero eso en lo que se refiere a teclear código, después reconozco que está muy sencillo configurar placas, usar librerías, toda la parte de soporte de hardware me parece muy buena.

Por eso para tener lo mejor de los 2 mundos tenés plugins para Visual Studio, Eclipse, y otros IDEs más completos:
http://playground.arduino.cc/Main/DevelopmentTools
Plugin para AVR studio:
http://www.visualmicro.com/

Me fuí por las ramas... que era lo que preguntabas?, ah sí!!!, usar el código C de Arduino. Fijate bien como es el tema de las licencias, en teoría si el código de Arduino esta licenciado para uso no comercial, y vos querés usar ese código para vender millones de unidades del SyncroMaster 7000, no sería ético usar ese código.
nnnnnnnnnnnnnnnaaaaaaaaaa ., nada que ver., es un micro esteping ., X e Y
vuelvo a repetir ., NO TENGO arduino ., asi que ni idea ., de como funciona el compilador​
bueno aca subo unas librerias que arme ., con lo que mas o menes me parece (si estoy equivocado por favor corrijan​
LIBRERIA .C
PHP:
// #############################################################################
// # lib_X_Y.c -  #
// #                                              # 
// #############################################################################
// #  <http://www.gnu.org/licenses/>.       #
// #############################################################################

#include "lib_X_Y.h"



// Inicializar Puertos 
extern void Init_X_Y_port( void )
 {
  
  DDR_COIL1 |= (1<<PIN_COIL1);
  DDR_COIL2 |= (1<<PIN_COIL2);
  DDR_COIL3 |= (1<<PIN_COIL3);
  DDR_COIL4 |= (1<<PIN_COIL4);
  DDR_COIL5 |= (1<<PIN_COIL5);
  DDR_COIL6 |= (1<<PIN_COIL6);
  DDR_COIL7 |= (1<<PIN_COIL7);
  DDR_COIL8 |= (1<<PIN_COIL8);
  

   }
 }
LIBRERIA .H
PHP:
// #############################################################################
// # lib_X_Y.h - x -Y  #
// #                                               # 
// #############################################################################
// #      <http://www.gnu.org/licenses/>.       #
// #############################################################################

#ifndef _X_Y_H
  #define _X_Y_H

  #include <avr/io.h>
  #include <stdint.h>
  #include <avr/interrupt.h>
  #include <util/delay.h>

  

  //macros puertos
  #define DDR_COIL1 DDRA
  #define PRT_COIL1 PORTA
  #define PIN_COIL1 PA0

  #define DDR_COIL2 DDRA
  #define PRT_COIL2 PORTA
  #define PIN_COIL2 PA1

  #define DDR_COIL3 DDRA
  #define PRT_COIL3 PORTA
  #define PIN_COIL3 PA2

  #define DDR_COIL4 DDRA
  #define PRT_COIL4 PORTA
  #define PIN_COIL4 PA3

  #define DDR_COIL5 DDRA
  #define PRT_COIL5 PORTA
  #define PIN_COIL5 PA4

  #define DDR_COIL6 DDRA
  #define PRT_COIL6 PORTA
  #define PIN_COIL6 PA5

  #define DDR_COIL7 DDRA
  #define PRT_COIL7 PORTA
  #define PIN_COIL7 PA6

  #define DDR_COIL8 DDRA
  #define PRT_COIL8 PORTA
  #define PIN_COIL8 PA7

 //Las funciones externas
extern void Init_X_Y_port( void );// Inicializar los puertos 
#endif
Si, Arduino tiene su Main.c dentro de este llama a setup() y loop(), de hecho la librería principal es Arduino.h, de ahí toma el resto, si importas esa librería está la posibilidad de que reconozca el código, el problema es si lo quieres importar para un chip que no está soportado por Arduino.
exacto amigo alli esta el problema ., uso atmega8515 ., no soportado por arduino​
 
Última edición:
#8
Bueno, si usas puerto entero entonces se facilita.
Código:
#define HIGH 1
#define LOW 0
void digitalWrite(int pin, int state){
   if(state){
      puerto |= (1 << (pin - 3));
   }
   else{
      puerto &= ~(1 << (pin-3));
   }
}
Algo así, no recuerdo como se llama el registro del puerto, pero eres para este una idea. La otra función, no se cual sería el equivalente en tus librerías.

Agrego que a mi parecer, esas ridículas tablas seria mejor reemplazarla por ciclos for con desplazamiento de carro, así en lugar de tener tantas solo tienes una función para contar los pasos que requieres.
 
Última edición:
#9
hola
Bueno, si usas puerto entero entonces se facilita.
Código:
#define HIGH 1
#define LOW 0
void digitalWrite(int pin, int state){
   if(state){
      puerto |= (1 << (pin - 3));
   }
   else{
      puerto &= ~(1 << (pin-3));
   }
}
Algo así, no recuerdo como se llama el registro del puerto, pero eres para este una idea. La otra función, no se cual sería el equivalente en tus librerías.
gracias amigaso por tu molestia para conmigo
bueno en realidad si miras el array original par arduino fijate que la secuencia es pin a pin (hay algunas sentencias que todavia no puedo deducir)​
pero vamos por partes ., ahora si se usa un mismo puerto pero son 8 salidas independientes ( fijate el codigo original )​
pero se separa en X e Y ., y hacen cosas distintas​
en cuanro a los puertos ., yo los declare asi ., porque me funcionaron en otros montajes ., pero si crees que es mejor ., despues los cambio ., eso no es problema​
basicamente pongo una sola funcion (de las 16 que tiene ) y obiamente las funcion X e Y ( cuatro puertos por funcion X o Y )​
Código:
// #############################################################################
// # lib_X_Y.c -  #
// #                                              # 
// #############################################################################
// #  <http://www.gnu.org/licenses/>.       #
// #############################################################################

#include "lib_X_Y.h"
#define HIGH 1
#define LOW 0


// Inicializar Puertos 
extern void Init_X_Y_port( void )
 {
  
  DDR_COIL1 |= (1<<PIN_COIL1);
  DDR_COIL2 |= (1<<PIN_COIL2);
  DDR_COIL3 |= (1<<PIN_COIL3);
  DDR_COIL4 |= (1<<PIN_COIL4);
  DDR_COIL5 |= (1<<PIN_COIL5);
  DDR_COIL6 |= (1<<PIN_COIL6);
  DDR_COIL7 |= (1<<PIN_COIL7);
  DDR_COIL8 |= (1<<PIN_COIL8);
  
   }
 }
void xplus16(){  //define function of 16 positive X steps 
     PRT_COIL1 |=  (1<<PIN_COIL1);
     PRT_COIL2 &= ~(1<<PIN_COIL2);
     PRT_COIL3 &= ~(1<<PIN_COIL3);
     PRT_COIL4 &= ~(1<<PIN_COIL4);
     PRT_COIL1 |=  (1<<PIN_COIL1);
     PRT_COIL2 |=  (1<<PIN_COIL2);
     PRT_COIL3 &= ~(1<<PIN_COIL3);
     PRT_COIL4 &= ~(1<<PIN_COIL4);                                                 
     PRT_COIL1 |=  (1<<PIN_COIL1);
     PRT_COIL2 &= ~(1<<PIN_COIL2);
     PRT_COIL3 &= ~(1<<PIN_COIL3);
     PRT_COIL4 &= ~(1<<PIN_COIL4);
     PRT_COIL1 |=  (1<<PIN_COIL1);
     PRT_COIL2 |=  (1<<PIN_COIL2);
     PRT_COIL3 &= ~(1<<PIN_COIL3);
     PRT_COIL4 &= ~(1<<PIN_COIL4);                                                                                                                       
     PRT_COIL1 |=  (1<<PIN_COIL1);                                                     
     PRT_COIL2 &= ~(1<<PIN_COIL2);
     PRT_COIL3 &= ~(1<<PIN_COIL3);
     PRT_COIL4 &= ~(1<<PIN_COIL4);
     PRT_COIL1 |=  (1<<PIN_COIL1);
     PRT_COIL2 |=  (1<<PIN_COIL2);
     PRT_COIL3 &= ~(1<<PIN_COIL3);
     PRT_COIL4 &= ~(1<<PIN_COIL4);                                                 
     PRT_COIL1 |=  (1<<PIN_COIL1);                                                     
     PRT_COIL2 &= ~(1<<PIN_COIL2);
     PRT_COIL3 &= ~(1<<PIN_COIL3);
     PRT_COIL4 &= ~(1<<PIN_COIL4);
     PRT_COIL1 |=  (1<<PIN_COIL1);
     PRT_COIL2 |=  (1<<PIN_COIL2);
     PRT_COIL3 &= ~(1<<PIN_COIL3);
     PRT_COIL4 &= ~(1<<PIN_COIL4);                                                 
     PRT_COIL1 |=  (1<<PIN_COIL1);                                                     
     PRT_COIL2 &= ~(1<<PIN_COIL2);
     PRT_COIL3 &= ~(1<<PIN_COIL3);
     PRT_COIL4 &= ~(1<<PIN_COIL4);
     PRT_COIL1 |=  (1<<PIN_COIL1);
     PRT_COIL2 |=  (1<<PIN_COIL2);
     PRT_COIL3 &= ~(1<<PIN_COIL3);
     PRT_COIL4 &= ~(1<<PIN_COIL4);                                                 
}                                                                                                                               void xminus1(){  //define function of 1 negative X steps
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
}                                                                                                                                                                                                                                                     void yplus16(){                                                                                         PRT_COIL1 |=  (1<<PIN_COIL1);
     PRT_COIL5 &= ~(1<<PIN_COIL5);
     PRT_COIL6 &= ~(1<<PIN_COIL6);
     PRT_COIL7 &= ~(1<<PIN_COIL7);
     PRT_COIL8 |=  (1<<PIN_COIL8);
     PRT_COIL5 |=  (1<<PIN_COIL5);
     PRT_COIL6 &= ~(1<<PIN_COIL6);
     PRT_COIL7 &= ~(1<<PIN_COIL7);                                                 
     PRT_COIL8 |=  (1<<PIN_COIL8);
     PRT_COIL5 &= ~(1<<PIN_COIL5);
     PRT_COIL6 &= ~(1<<PIN_COIL6);
     PRT_COIL7 &= ~(1<<PIN_COIL7);
     PRT_COIL8 |=  (1<<PIN_COIL8);
     PRT_COIL5 |=  (1<<PIN_COIL5);
     PRT_COIL6 &= ~(1<<PIN_COIL6);
     PRT_COIL7 &= ~(1<<PIN_COIL7);                                                                                                                       
     PRT_COIL8 |=  (1<<PIN_COIL8);                                                     
     PRT_COIL5 &= ~(1<<PIN_COIL5);
     PRT_COIL6 &= ~(1<<PIN_COIL6);
     PRT_COIL7 &= ~(1<<PIN_COIL7);
     PRT_COIL8 |=  (1<<PIN_COIL8);
     PRT_COIL5 |=  (1<<PIN_COIL5);
     PRT_COIL6 &= ~(1<<PIN_COIL6);
     PRT_COIL7 &= ~(1<<PIN_COIL7);                                                 
     PRT_COIL8 |=  (1<<PIN_COIL8);                                                     
     PRT_COIL5 &= ~(1<<PIN_COIL5);
     PRT_COIL6 &= ~(1<<PIN_COIL6);
     PRT_COIL7 &= ~(1<<PIN_COIL7);
     PRT_COIL8 |=  (1<<PIN_COIL8);
     PRT_COIL5 |=  (1<<PIN_COIL5);
     PRT_COIL6 &= ~(1<<PIN_COIL6);
     PRT_COIL7 &= ~(1<<PIN_COIL7);                                                 
     PRT_COIL8 |=  (1<<PIN_COIL8);                                                     
     PRT_COIL5 &= ~(1<<PIN_COIL5);
     PRT_COIL6 &= ~(1<<PIN_COIL6);
     PRT_COIL7 &= ~(1<<PIN_COIL7);
     PRT_COIL8 |=  (1<<PIN_COIL8);
     PRT_COIL5 |=  (1<<PIN_COIL5);
     PRT_COIL6 &= ~(1<<PIN_COIL6);
     PRT_COIL7 &= ~(1<<PIN_COIL7);                                                                               }                                                                                                                            void loop(){
  yplus4();
  xplus4();
  yplus4();
  xminus4();
  yminus4();
  xplus4();
  yminus4();
  xminus4();  
}
 
Última edición:
#10
Son 8 salidas independientes del 3 al 10, tú estás usando un puerto completo, lo que hace mi función es traducir directamente el digitalWrite() a 8 pines del mismo puerto. En lugar de escribir los pines 3~10 que en el Arduino ocupa dos puertos, aquí lo hace en los pines 0~7 del mismo puerto con esto no necesitas reescribir todo, solo agregas la función y las series las copias como están, solo faltaría la de delayMicroseconds() pero no sabría cual función para delay implementa tu IDE.

Por mi parte, te recomendaría usar ciclos for y desplazamiento de carro para crear una función que rote los bits N veces en lugar de tener una función para cada N ves y el probable desperdicio de memoria.
 
#12
Hola
Ups, entendí mal, mis disculpas
gracias amigo ., pero aunque no lo creas ., me fuiste de mucha utilidad​
tu idea de instalar el AVRstudio 7 ., esta genial ., se lo recomiendo al que use arduino ., es lo mismo ., pero esta integrado con AVRGcc y ASM​
o sea se pueden llevar los codigos a otros micros que no son arduino​
si es asi ¿¿¿ cual es el problema que tengo ???? ., mi maquina es muy vieja (256 de ram) y no lo soporta al IDE ., se congela (y pantallazo azul) pero por lo que me indicaste .,vi los ejemplos en internet., lleva su trabajo pero se puede hacer con la guia del IDE​
Hola y gracias amigo
Son 8 salidas independientes del 3 al 10, tú estás usando un puerto completo, lo que hace mi función es traducir directamente el digitalWrite() a 8 pines del mismo puerto. En lugar de escribir los pines 3~10 que en el Arduino ocupa dos puertos, aquí lo hace en los pines 0~7 del mismo puerto con esto no necesitas reescribir todo, solo agregas la función y las series las copias como están, solo faltaría la de delayMicroseconds() pero no sabría cual función para delay implementa tu IDE.

Por mi parte, te recomendaría usar ciclos for y desplazamiento de carro para crear una función que rote los bits N veces en lugar de tener una función para cada N ves y el probable desperdicio de memoria.
estuve estudiando un poco y encontre otro programa (tambien para arduino)el problema es que es muchisimo mas complejo ., y por lo tanto mas dificil de traspasar a C​
ante todo amigo ., darte las gracias y pedirte disculpas por no entenderte antes​
tu idea es genial ( asi me lo indica mi compilador) ., la libreria la estoy armando dentro del IDE​
encuanto ala memoria no te hagas problema (menos de 1Kb) ., sobra muchisimo lugar jejejejejejejeje​
por empezar te publico el IO.h del micro asi ves su definiciones ., para que tengas una idea de que sentencias acepta el IDE ( sobre todo los puertos ., par tu idea)​
en cuanto ala linea que escribiste lo cambie por PORTA ., ya que no me reconoce la directiva de PUERTOS​
no cambie la definicion de "pin" ., ya que cuando lo definis con PIN ., alli lo colocas como entrada ., y aqui se usa como salida​
por eso te publico el I/O .h asi te fijas cual definicion es para lo que tenes pensado​
PHP:
/* Copyright (c) 2002, Steinar Haugen
   All rights reserved.

   Redistribution and use in source and binary forms, with or without
   modification, are permitted provided that the following conditions are met:

   * Redistributions of source code must retain the above copyright
     notice, this list of conditions and the following disclaimer.

   * Redistributions in binary form must reproduce the above copyright
     notice, this list of conditions and the following disclaimer in
     the documentation and/or other materials provided with the
     distribution.

   * Neither the name of the copyright holders nor the names of
     contributors may be used to endorse or promote products derived
     from this software without specific prior written permission.

  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  POSSIBILITY OF SUCH DAMAGE. */

/* $Id: iom8515.h,v 1.10.2.5 2008/10/17 23:27:50 arcanum Exp $ */

/* avr/iom8515.h - definitions for ATmega8515 */

#ifndef _AVR_IOM8515_H_
#define _AVR_IOM8515_H_ 1

/* This file should only be included from <avr/io.h>, never directly. */

#ifndef _AVR_IO_H_
#  error "Include <avr/io.h> instead of this file."
#endif

#ifndef _AVR_IOXXX_H_
#  define _AVR_IOXXX_H_ "iom8515.h"
#else
#  error "Attempt to include more than one <avr/ioXXX.h> file."
#endif 

/* I/O registers */

/* Oscillator Calibration Register */
#define OSCCAL  _SFR_IO8(0x04)

/* Input Pins, Port E */
#define PINE    _SFR_IO8(0x05)

/* Data Direction Register, Port E */
#define DDRE    _SFR_IO8(0x06)

/* Data Register, Port E */
#define PORTE   _SFR_IO8(0x07)

/* Analog Comparator Control and Status Register */
#define ACSR    _SFR_IO8(0x08)

/* USART Baud Rate Register */
#define UBRRL   _SFR_IO8(0x09)

/* USART Control and Status Register B */
#define UCSRB   _SFR_IO8(0x0A)

/* USART Control and Status Register A */
#define UCSRA   _SFR_IO8(0x0B)

/* USART I/O Data Register */
#define UDR     _SFR_IO8(0x0C)

/* SPI Control Register */
#define SPCR    _SFR_IO8(0x0D)

/* SPI Status Register */
#define SPSR    _SFR_IO8(0x0E)

/* SPI I/O Data Register */
#define SPDR    _SFR_IO8(0x0F)

/* Input Pins, Port D */
#define PIND    _SFR_IO8(0x10)

/* Data Direction Register, Port D */
#define DDRD    _SFR_IO8(0x11)

/* Data Register, Port D */
#define PORTD   _SFR_IO8(0x12)

/* Input Pins, Port C */
#define PINC    _SFR_IO8(0x13)

/* Data Direction Register, Port C */
#define DDRC    _SFR_IO8(0x14)

/* Data Register, Port C */
#define PORTC   _SFR_IO8(0x15)

/* Input Pins, Port B */
#define PINB    _SFR_IO8(0x16)

/* Data Direction Register, Port B */
#define DDRB    _SFR_IO8(0x17)

/* Data Register, Port B */
#define PORTB   _SFR_IO8(0x18)

/* Input Pins, Port A */
#define PINA    _SFR_IO8(0x19)

/* Data Direction Register, Port A */
#define DDRA    _SFR_IO8(0x1A)

/* Data Register, Port A */
#define PORTA   _SFR_IO8(0x1B)

/* EEPROM Control Register */
#define EECR	_SFR_IO8(0x1C)

/* EEPROM Data Register */
#define EEDR	_SFR_IO8(0x1D)

/* EEPROM Address Register */
#define EEAR	_SFR_IO16(0x1E)
#define EEARL	_SFR_IO8(0x1E)
#define EEARH	_SFR_IO8(0x1F)

/* USART Baud Rate Register HI         */
/* USART Control and Status Register C */
#define UBRRH   _SFR_IO8(0x20)
#define UCSRC   UBRRH

/* Watchdog Timer Control Register */
#define WDTCR   _SFR_IO8(0x21)

/* T/C 1 Input Capture Register */
#define ICR1    _SFR_IO16(0x24)
#define ICR1L   _SFR_IO8(0x24)
#define ICR1H   _SFR_IO8(0x25)

/* Timer/Counter1 Output Compare Register B */
#define OCR1B   _SFR_IO16(0x28)
#define OCR1BL  _SFR_IO8(0x28)
#define OCR1BH  _SFR_IO8(0x29)

/* Timer/Counter1 Output Compare Register A */
#define OCR1A   _SFR_IO16(0x2A)
#define OCR1AL  _SFR_IO8(0x2A)
#define OCR1AH  _SFR_IO8(0x2B)

/* Timer/Counter 1 */
#define TCNT1   _SFR_IO16(0x2C)
#define TCNT1L  _SFR_IO8(0x2C)
#define TCNT1H  _SFR_IO8(0x2D)

/* Timer/Counter 1 Control and Status Register */
#define TCCR1B  _SFR_IO8(0x2E)

/* Timer/Counter 1 Control Register */
#define TCCR1A  _SFR_IO8(0x2F)

/* Special Function IO Register */
#define SFIOR   _SFR_IO8(0x30)

/* Timer/Counter 0 Output Compare Register */
#define OCR0    _SFR_IO8(0x31)

/* Timer/Counter 0 */
#define TCNT0   _SFR_IO8(0x32)

/* Timer/Counter 0 Control Register */
#define TCCR0   _SFR_IO8(0x33)

/* MCU Control and Status Register */
#define MCUCSR  _SFR_IO8(0x34)

/* MCU Control Register */
#define MCUCR   _SFR_IO8(0x35)

/* Extended MCU Control Register */
#define EMCUCR  _SFR_IO8(0x36)

/* Store Program Memory Control Register */
#define SPMCR   _SFR_IO8(0x37)

/* Timer/Counter Interrupt Flag register */
#define TIFR    _SFR_IO8(0x38)

/* Timer/Counter Interrupt MaSK register */
#define TIMSK   _SFR_IO8(0x39)

/* General Interrupt Flag Register */
#define GIFR    _SFR_IO8(0x3A)

/* General Interrupt Control Register */
#define GICR    _SFR_IO8(0x3B)

/* 0x3D..0x3E SP */

/* 0x3F SREG */

/* Interrupt vectors */

/* External Interrupt Request 0 */
#define INT0_vect			_VECTOR(1)
#define SIG_INTERRUPT0			_VECTOR(1)

/* External Interrupt Request 1 */
#define INT1_vect			_VECTOR(2)
#define SIG_INTERRUPT1			_VECTOR(2)

/* Timer/Counter1 Capture Event */
#define TIMER1_CAPT_vect		_VECTOR(3)
#define SIG_INPUT_CAPTURE1		_VECTOR(3)

/* Timer/Counter1 Compare Match A */
#define TIMER1_COMPA_vect		_VECTOR(4)
#define SIG_OUTPUT_COMPARE1A		_VECTOR(4)

/* Timer/Counter1 Compare MatchB */
#define TIMER1_COMPB_vect		_VECTOR(5)
#define SIG_OUTPUT_COMPARE1B		_VECTOR(5)

/* Timer/Counter1 Overflow */
#define TIMER1_OVF_vect			_VECTOR(6)
#define SIG_OVERFLOW1			_VECTOR(6)

/* Timer/Counter0 Overflow */
#define TIMER0_OVF_vect			_VECTOR(7)
#define SIG_OVERFLOW0			_VECTOR(7)

/* Serial Transfer Complete */
#define SPI_STC_vect			_VECTOR(8)
#define SIG_SPI				_VECTOR(8)

/* UART, Rx Complete */
#define USART_RX_vect                   _VECTOR(9)
#define UART_RX_vect                    _VECTOR(9) /* For compatability only */
#define SIG_UART_RECV                   _VECTOR(9) /* For compatability only */

/* UART Data Register Empty */
#define USART_UDRE_vect                 _VECTOR(10)
#define UART_UDRE_vect                  _VECTOR(10) /* For compatability only */
#define SIG_UART_DATA                   _VECTOR(10) /* For compatability only */

/* UART, Tx Complete */
#define USART_TX_vect                   _VECTOR(11)
#define UART_TX_vect                    _VECTOR(11) /* For compatability only */
#define SIG_UART_TRANS                  _VECTOR(11) /* For compatability only */

/* Analog Comparator */
#define ANA_COMP_vect			_VECTOR(12)
#define SIG_COMPARATOR			_VECTOR(12)

/* External Interrupt Request 2 */
#define INT2_vect			_VECTOR(13)
#define SIG_INTERRUPT2			_VECTOR(13)

/* Timer 0 Compare Match */
#define TIMER0_COMP_vect		_VECTOR(14)
#define SIG_OUTPUT_COMPARE0		_VECTOR(14)

/* EEPROM Ready */
#define EE_RDY_vect			_VECTOR(15)
#define SIG_EEPROM_READY		_VECTOR(15)

/* Store Program Memory Ready */
#define SPM_RDY_vect			_VECTOR(16)
#define SIG_SPM_READY			_VECTOR(16)

#define _VECTORS_SIZE 34

/*
   The Register Bit names are represented by their bit number (0-7).
*/

/* General Interrupt Control Register */
#define    INT1         7
#define    INT0         6
#define    INT2         5
#define    IVSEL        1
#define    IVCE         0

/* General Interrupt Flag Register */
#define    INTF1        7
#define    INTF0        6
#define    INTF2        5

/* Timer/Counter Interrupt MaSK Register */
#define    TOIE1        7
#define    OCIE1A       6
#define    OCIE1B       5
#define    TICIE1       3
#define    TOIE0        1
#define    OCIE0        0

/* Timer/Counter Interrupt Flag Register */
#define    TOV1         7
#define    OCF1A        6
#define    OCF1B        5
#define    ICF1         3
#define    TOV0         1
#define    OCF0         0

/* Store Program Memory Control Register */
#define    SPMIE        7
#define    RWWSB        6
#define    RWWSRE       4
#define    BLBSET       3
#define    PGWRT        2
#define    PGERS        1
#define    SPMEN        0

/* Extended MCU Control Register */
#define    SM0          7
#define    SRL2         6
#define    SRL1         5
#define    SRL0         4
#define    SRW01        3
#define    SRW00        2
#define    SRW11        1
#define    ISC2         0

/* MCU Control Register */
#define    SRE          7
#define    SRW10        6
#define    SE           5
#define    SM1          4
#define    ISC11        3
#define    ISC10        2
#define    ISC01        1
#define    ISC00        0

/* MCU Control and Status Register */
#define    SM2          5
#define    WDRF         3
#define    BORF         2
#define    EXTRF        1
#define    PORF         0

/* Timer/Counter 0 Control Register */
#define    FOC0         7
#define    WGM00        6
#define    COM01        5
#define    COM00        4
#define    WGM01        3
#define    CS02         2
#define    CS01         1
#define    CS00         0

/* Special Function IO Register */
#define    XMBK         6
#define    XMM2         5
#define    XMM1         4
#define    XMM0         3
#define    PUD          2
#define    PSR10        0

/* Timer/Counter 1 Control Register */
#define    COM1A1       7
#define    COM1A0       6
#define    COM1B1       5
#define    COM1B0       4
#define    FOC1A        3
#define    FOC1B        2
#define    WGM11        1
#define    WGM10        0

/* Timer/Counter 1 Control and Status Register */
#define    ICNC1        7
#define    ICES1        6
#define    WGM13        4
#define    WGM12        3
#define    CS12         2
#define    CS11         1
#define    CS10         0

/* Watchdog Timer Control Register */
#define    WDCE         4
#define    WDE          3
#define    WDP2         2
#define    WDP1         1
#define    WDP0         0

/* USART Control and Status Register C */
#define    URSEL        7
#define    UMSEL        6
#define    UPM1         5
#define    UPM0         4
#define    USBS         3
#define    UCSZ1        2
#define    UCSZ0        1
#define    UCPOL        0

/* Data Register, Port A */
#define    PA7          7
#define    PA6          6
#define    PA5          5
#define    PA4          4
#define    PA3          3
#define    PA2          2
#define    PA1          1
#define    PA0          0

/* Data Direction Register, Port A */
#define    DDA7         7
#define    DDA6         6
#define    DDA5         5
#define    DDA4         4
#define    DDA3         3
#define    DDA2         2
#define    DDA1         1
#define    DDA0         0

/* Input Pins, Port A */
#define    PINA7        7
#define    PINA6        6
#define    PINA5        5
#define    PINA4        4
#define    PINA3        3
#define    PINA2        2
#define    PINA1        1
#define    PINA0        0

/* Data Register, Port B */
#define    PB7          7
#define    PB6          6
#define    PB5          5
#define    PB4          4
#define    PB3          3
#define    PB2          2
#define    PB1          1
#define    PB0          0

/* Data Direction Register, Port B */
#define    DDB7         7
#define    DDB6         6
#define    DDB5         5
#define    DDB4         4
#define    DDB3         3
#define    DDB2         2
#define    DDB1         1
#define    DDB0         0

/* Input Pins, Port B */
#define    PINB7        7
#define    PINB6        6
#define    PINB5        5
#define    PINB4        4
#define    PINB3        3
#define    PINB2        2
#define    PINB1        1
#define    PINB0        0

/* Data Register, Port C */
#define    PC7          7
#define    PC6          6
#define    PC5          5
#define    PC4          4
#define    PC3          3
#define    PC2          2
#define    PC1          1
#define    PC0          0

/* Data Direction Register, Port C */
#define    DDC7         7
#define    DDC6         6
#define    DDC5         5
#define    DDC4         4
#define    DDC3         3
#define    DDC2         2
#define    DDC1         1
#define    DDC0         0

/* Input Pins, Port C */
#define    PINC7        7
#define    PINC6        6
#define    PINC5        5
#define    PINC4        4
#define    PINC3        3
#define    PINC2        2
#define    PINC1        1
#define    PINC0        0

/* Data Register, Port D */
#define    PD7          7
#define    PD6          6
#define    PD5          5
#define    PD4          4
#define    PD3          3
#define    PD2          2
#define    PD1          1
#define    PD0          0

/* Data Direction Register, Port D */
#define    DDD7         7
#define    DDD6         6
#define    DDD5         5
#define    DDD4         4
#define    DDD3         3
#define    DDD2         2
#define    DDD1         1
#define    DDD0         0

/* Input Pins, Port D */
#define    PIND7        7
#define    PIND6        6
#define    PIND5        5
#define    PIND4        4
#define    PIND3        3
#define    PIND2        2
#define    PIND1        1
#define    PIND0        0

/* SPI Status Register */
#define    SPIF         7
#define    WCOL         6
#define    SPI2X        0

/* SPI Control Register */
#define    SPIE         7
#define    SPE          6
#define    DORD         5
#define    MSTR         4
#define    CPOL         3
#define    CPHA         2
#define    SPR1         1
#define    SPR0         0

/* USART Control and Status Register A */
#define    RXC          7
#define    TXC          6
#define    UDRE         5
#define    FE           4
#define    DOR          3
#define    PE           2
#define    U2X          1
#define    MPCM         0

/* USART Control and Status Register B */
#define    RXCIE        7
#define    TXCIE        6
#define    UDRIE        5
#define    RXEN         4
#define    TXEN         3
#define    UCSZ2        2
#define    RXB8         1
#define    TXB8         0

/* Analog Comparator Control and Status Register */
#define    ACD          7
#define    ACBG         6
#define    ACO          5
#define    ACI          4
#define    ACIE         3
#define    ACIC         2
#define    ACIS1        1
#define    ACIS0        0

/* Data Register, Port E */
#define    PE2          2
#define    PE1          1
#define    PE0          0

/* Data Direction Register, Port E */
#define    DDE2         2
#define    DDE1         1
#define    DDE0         0

/* Input Pins, Port E */
#define    PINE2        2
#define    PINE1        1
#define    PINE0        0

/* EEPROM Control Register */
#define    EERIE        3
#define    EEMWE        2
#define    EEWE         1
#define    EERE         0

/* Constants */
#define SPM_PAGESIZE 64
#define RAMEND       0x25F    /* Last On-Chip SRAM Location */
#define XRAMEND      0xFFFF
#define E2END        0x1FF
#define E2PAGESIZE   4
#define FLASHEND     0x1FFF


/* Fuses */

#define FUSE_MEMORY_SIZE 2

/* Low Fuse Byte */
#define FUSE_CKSEL0      (unsigned char)~_BV(0)
#define FUSE_CKSEL1      (unsigned char)~_BV(1)
#define FUSE_CKSEL2      (unsigned char)~_BV(2)
#define FUSE_CKSEL3      (unsigned char)~_BV(3)
#define FUSE_SUT0        (unsigned char)~_BV(4)
#define FUSE_SUT1        (unsigned char)~_BV(5)
#define FUSE_BODEN       (unsigned char)~_BV(6)
#define FUSE_BODLEVEL    (unsigned char)~_BV(7)
#define LFUSE_DEFAULT (FUSE_CKSEL1 & FUSE_CKSEL2 & FUSE_CKSEL3 & FUSE_SUT0)

/* High Fuse Byte */
#define FUSE_BOOTRST     (unsigned char)~_BV(0)
#define FUSE_BOOTSZ0     (unsigned char)~_BV(1)
#define FUSE_BOOTSZ1     (unsigned char)~_BV(2)
#define FUSE_EESAVE      (unsigned char)~_BV(3)
#define FUSE_CKOPT       (unsigned char)~_BV(4)
#define FUSE_SPIEN       (unsigned char)~_BV(5)
#define FUSE_WDTON       (unsigned char)~_BV(6)
#define FUSE_S8515C      (unsigned char)~_BV(7)
#define HFUSE_DEFAULT (FUSE_BOOTSZ0 & FUSE_BOOTSZ1 & FUSE_SPIEN)


/* Lock Bits */
#define __LOCK_BITS_EXIST
#define __BOOT_LOCK_BITS_0_EXIST
#define __BOOT_LOCK_BITS_1_EXIST 


/* Signature */
#define SIGNATURE_0 0x1E
#define SIGNATURE_1 0x93
#define SIGNATURE_2 0x06


#endif /* _AVR_IOM8515_H_ */
bueno en cuanto a los delay ., por aca te pongo unos ejemplos de lo que reconoce el IDE (te pongo como adjunto los txt completos​
PHP:
Function _delay_us()                                                                                                   void _delay_us(
	double __us)                                                                                                       Realizar un retraso de microsegundos __us, utilizando _delay_loop_1 ().
y aca la otra que tambien admite​
PHP:
Function _delay_ms()                                                                                                 void _delay_ms(
	double __ms)                                                                                                      Realizar un retraso de __ms milisegundos, utilizando _delay_loop_2 ().
y por aca un ejemplo real de uso ( sacado de una compilacion funcionando​
PHP:
#define F_CPU 1000000UL
#include <avr/io.h>
#include <util/delay.h>

int main(void)
{
    DDRB   |= (1 << PB2);           // LED on pin PB2
    
    while(1)
    {
        _delay_ms(50);              // 50ms delay
        PORTB &= ~(1 << PB2);       // LED off
        _delay_ms(50);              // 50ms delay
        PORTB |=  (1 << PB2);       // LED on
    }
}
como veras seguidamente te muestro los cambios ( no esta la funcion delay porque no entiendo como funciona en el arduino)​
PHP:
  #include <avr/io.h>
  #include <stdint.h>
  #include <avr/interrupt.h>
  #include <util/delay.h>
  #include <stdio.h>

#define F_CPU 8000000

#define HIGH 1
#define LOW 0

//*** Inicialización pines / port ***// 
void init_pinouts(){ 

    DDRA=  0xFF;		// salidas bajas
    PORTA= 0;
   }

void digitalWrite(int pin, int state){
   if(state){
      PORTA |= (1 << (pin- 3));
   }
   else{
      PORTA &= ~(1 << (pin-3));
   }
}



void setup(){  //
//  pinMode(3, OUTPUT);
//  pinMode(4, OUTPUT);
//  pinMode(5, OUTPUT);
//  pinMode(6, OUTPUT);
//  pinMode(7, OUTPUT);
//  pinMode(8, OUTPUT);
//  pinMode(9, OUTPUT);
//  pinMode(10, OUTPUT);
}

int tON = 2750;  //declarar el tiempo alto del pulso
int tOFF = 250;  //declarar el tiempo bajo del pulso



void xplus16(){  // define función de 16 pasos positivos X 
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
}
     
void xplus15(){ //define función de 15 pasos positivos X 
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
}
 
void xplus14(){  //define función de 14 pasos positivos X 
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
}

void xplus13(){  // define función de 13 pasos positivos X 
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
}

void xplus12(){  // define función de 12 pasos positivos X 
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
}

void xplus11(){  // define función de 11 pasos positivos X 
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
}

void xplus10(){  //define función de 10 pasos positivos X  
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
}

void xplus9(){  //define función de 9 pasos positivos X 
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
}

void xplus8(){  // define función de 8 pasos positivos X 
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
}

void xplus7(){  // define función de 7 pasos positivos X 
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
}

void xplus6(){  // define función de 6 pasos positivos X 
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
}

void xplus5(){  //define función de 5 pasos positivos X 
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
}

void xplus4(){  // define función de 4 pasos positivos X 
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
}

void xplus3(){  // define función de 3 pasos positivos X 
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
}

void xplus2(){  // define función de 2 pasos positivos X  
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
}

void xplus1(){  // define función de 1 pasos positivos X 
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
}
  
void xminus16(){  // define función de 16 pasos negativos X
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
}   

void xminus15(){  // define función de 15 pasos negativos X
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
}

void xminus14(){  // define función de 14 pasos negativos X/
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
}

void xminus13(){  // define función de 13 pasos negativos X
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
}

void xminus12(){  // define función de 12 pasos negativos X
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
}

void xminus11(){  // define función de 11 pasos negativos X 
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
}

void xminus10(){  // define función de 10 pasos negativos X
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
}

void xminus9(){  // define función de 9 pasos negativos X
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
}

void xminus8(){  // define función de 8 pasos negativos X
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
}

void xminus7(){  // define función de 7 pasos negativos X
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
}

void xminus6(){  // define función de 6 pasos negativos X
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
}

void xminus5(){  // define función de 5 pasos negativos X
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
}

void xminus4(){  // define función de 4 pasos negativos X
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
}

void xminus3(){  // define función de 3 pasos negativos X
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
}

void xminus2(){  // define función de 2 pasos negativos X
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
}

void xminus1(){  // define función de 1 pasos negativos X
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
}
    
    
void yplus16(){
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
}

void yplus15(){
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
}
  
void yplus14(){
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
}

void yplus13(){
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
}

void yplus12(){
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
}

void yplus11(){
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
}

void yplus10(){
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
}

void yplus9(){
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
}

void yplus8(){
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
}

void yplus7(){
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
}

void yplus6(){
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
}

void yplus5(){
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
}

void yplus4(){
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
}

void yplus3(){
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
}

void yplus2(){
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
}

void yplus1(){
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
}    
    
void yminus16(){
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
}

void yminus15(){
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
}

void yminus14(){
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
}

void yminus13(){
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
}

void yminus12(){
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
}

void yminus11(){
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
}

void yminus10(){
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
}

void yminus9(){
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
}
 
void yminus8(){
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
}

void yminus7(){
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
}

void yminus6(){
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
}

void yminus5(){
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
}

void yminus4(){
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
}

void yminus3(){
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
}

void yminus2(){
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
}

void yminus1(){
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
}
     
void loop(){
  yplus4();
  xplus4();
  yplus4();
  xminus4();
  yminus4();
  xplus4();
  yminus4();
  xminus4();  
}
en cuanto atu idea de implemetacion ., me parece correcta ., pero no puedo aportar nada ., por que me imagino algo ., pero puntualmente ., no se como seria​
y agradecido por las molestias ., y esperando sus respuestas
 

Adjuntos

Última edición:
#13
Se que PINA seria el registro d e lectura del puerto A, solo lo llame pin pero es una variable local, no un registro, podría llamarse como sea, en cuanto a delayMicroseconds() creo que podría quedar como
#define delayMicroseconds(x) _delay_us(x)

Como dices, la función que propuse solo mapea a un puerto, era para evitar tener que reescribir todas las secuencias, no es conveniente usarla si agregas más llamadas a otros pines de Arduino que no sean esos 8, en tal caso habría que crear una que permita mapear todos los pines.
 
Última edición:
#14
Hola
gracias amigo ., pero aunque no lo creas ., me fuiste de mucha utilidad​
tu idea de instalar el AVRstudio 7 ., esta genial ., se lo recomiendo al que use arduino ., es lo mismo ., pero esta integrado con AVRGcc y ASM​
<div align="left">o sea se pueden llevar los codigos a otros micros que no son arduino
Jajaja, esta bien, si te dan limones haz limonada... :D

...
PHP:
   #include <avr/io.h>
  #include <stdint.h>
  #include <avr/interrupt.h>
  #include <util/delay.h>
  #include <stdio.h>

#define F_CPU 8000000

#define HIGH 1
#define LOW 0

//*** Inicialización pines / port ***// 
void init_pinouts(){ 

    DDRA=  0xFF;        // salidas bajas
    PORTA= 0;
   }

void digitalWrite(int pin, int state){
   if(state){
      PORTA |= (1 << (pin- 3));
   }
   else{
      PORTA &= ~(1 << (pin-3));
   }
}



void setup(){  //
//  pinMode(3, OUTPUT);
//  pinMode(4, OUTPUT);
//  pinMode(5, OUTPUT);
//  pinMode(6, OUTPUT);
//  pinMode(7, OUTPUT);
//  pinMode(8, OUTPUT);
//  pinMode(9, OUTPUT);
//  pinMode(10, OUTPUT);
}

int tON = 2750;  //declarar el tiempo alto del pulso
int tOFF = 250;  //declarar el tiempo bajo del pulso



void xplus16(){  // define función de 16 pasos positivos X 
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
}
     
void xplus15(){ //define función de 15 pasos positivos X 
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
}
 
void xplus14(){  //define función de 14 pasos positivos X 
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
}

void xplus13(){  // define función de 13 pasos positivos X 
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
}

void xplus12(){  // define función de 12 pasos positivos X 
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
}

void xplus11(){  // define función de 11 pasos positivos X 
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
}

void xplus10(){  //define función de 10 pasos positivos X  
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
}

void xplus9(){  //define función de 9 pasos positivos X 
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
}

void xplus8(){  // define función de 8 pasos positivos X 
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
}

void xplus7(){  // define función de 7 pasos positivos X 
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
}

void xplus6(){  // define función de 6 pasos positivos X 
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
}

void xplus5(){  //define función de 5 pasos positivos X 
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
}

void xplus4(){  // define función de 4 pasos positivos X 
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
}

void xplus3(){  // define función de 3 pasos positivos X 
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
}

void xplus2(){  // define función de 2 pasos positivos X  
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
}

void xplus1(){  // define función de 1 pasos positivos X 
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
}
  
void xminus16(){  // define función de 16 pasos negativos X
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
}   

void xminus15(){  // define función de 15 pasos negativos X
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
}

void xminus14(){  // define función de 14 pasos negativos X/
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
}

void xminus13(){  // define función de 13 pasos negativos X
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
}

void xminus12(){  // define función de 12 pasos negativos X
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
}

void xminus11(){  // define función de 11 pasos negativos X 
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
}

void xminus10(){  // define función de 10 pasos negativos X
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
}

void xminus9(){  // define función de 9 pasos negativos X
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
}

void xminus8(){  // define función de 8 pasos negativos X
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
}

void xminus7(){  // define función de 7 pasos negativos X
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
}

void xminus6(){  // define función de 6 pasos negativos X
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
}

void xminus5(){  // define función de 5 pasos negativos X
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
}

void xminus4(){  // define función de 4 pasos negativos X
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(3, LOW);
  delayMicroseconds(tOFF);
}

void xminus3(){  // define función de 3 pasos negativos X
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(4, LOW);
  delayMicroseconds(tOFF);
}

void xminus2(){  // define función de 2 pasos negativos X
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(5, LOW);
  delayMicroseconds(tOFF);
}

void xminus1(){  // define función de 1 pasos negativos X
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
}
    
    
void yplus16(){
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
}

void yplus15(){
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
}
  
void yplus14(){
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
}

void yplus13(){
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
}

void yplus12(){
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
}

void yplus11(){
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
}

void yplus10(){
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
}

void yplus9(){
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
}

void yplus8(){
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
}

void yplus7(){
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
}

void yplus6(){
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
}

void yplus5(){
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
}

void yplus4(){
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
}

void yplus3(){
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
}

void yplus2(){
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
}

void yplus1(){
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
}    
    
void yminus16(){
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
}

void yminus15(){
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
}

void yminus14(){
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
}

void yminus13(){
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
}

void yminus12(){
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
}

void yminus11(){
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
}

void yminus10(){
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
}

void yminus9(){
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
}
 
void yminus8(){
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
}

void yminus7(){
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
}

void yminus6(){
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
}

void yminus5(){
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
}

void yminus4(){
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(7, LOW);
  delayMicroseconds(tOFF);
}

void yminus3(){
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(8, HIGH);
  delayMicroseconds(tON);
  digitalWrite(8, LOW);
  delayMicroseconds(tOFF);
}

void yminus2(){
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(9, HIGH);
  delayMicroseconds(tON);
  digitalWrite(9, LOW);
  delayMicroseconds(tOFF);
}

void yminus1(){
  digitalWrite(10, HIGH);
  delayMicroseconds(tON);
  digitalWrite(10, LOW);
  delayMicroseconds(tOFF);
}
     
void loop(){
  yplus4();
  xplus4();
  yplus4();
  xminus4();
  yminus4();
  xplus4();
  yminus4();
  xminus4();  
}
Guau.... eso es un montón de código para las funciones de pasos... se puede simplificar bastante, ejemplo para el eje X:

PHP:
#define TAMANO_SECUENCIA 4

unsigned int ObtenerPinProximoPaso( unsigned int pasoActual, 
   unsigned int adelante) {
  if(adelante) {
    pasoActual++;
    if (pasoActual >= TAMANO_SECUENCIA) {
      pasoActual = 0;
    }
  } else {
    if (pasoActual == 0) {
      pasoActual = TAMANO_SECUENCIA - 1;
    } else {
      pasoActual--;
    }
  }
  return pasoActual;
}

const unsigned int secuenciaPasosX[TAMANO_SECUENCIA] = {3,4,5,6};
unsigned int pasoActualX = 0;

void PasosX(int cuenta){
  unsigned int direccion, i;

  if(cuenta >= 0) {
    direccion = 1;
  } else {
    direccion = 0;
    cuenta = -cuenta;
  }
  
  for ( i = 0 ; i < cuenta ; --i ) {
    pasoActualX = ObtenerPinProximoPaso(pasoActualX, direccion);
    digitalWrite( secuenciaPasosX[pasoActualX] , HIGH );
    delayMicroseconds(tON);
    digitalWrite( secuenciaPasosX[pasoActualX] , LOW);
    delayMicroseconds(tOFF);
  }
}
Similar para el eje Y... aunque tampoco haría falta funciones distintas para los ejes X e Y, solo pasar un puntero más que sería al array secuenciaPasosX o secuenciaPasosY, más paso actual, más cuenta de pasos.
Ojo no probé nada del código de arriba, es solo para hablar del concepto.
Saludos.
 
Última edición:
#15
hola queridos amigos ., y infinitamente agradecido por la guia y tiempo gastado en mi
Se que PINA seria el registro d e lectura del puerto A, solo lo llame pin pero es una variable local, no un registro, podría llamarse como sea, en cuanto a delayMicroseconds() creo que podría quedar como
#define delayMicroseconds(x) _delay_us(x)

Como dices, la función que propuse solo mapea a un puerto, era para evitar tener que reescribir todas las secuencias, no es conveniente usarla si agregas más llamadas a otros pines de Arduino que no sean esos 8, en tal caso habría que crear una que permita mapear todos los pines.
querido amigo Nuyel bueno estuve trabajando en la libreria y avanzo todo bien ., hasta que me salto el error ., de la funcion y definicion de "" digitalWrite ""​
hasta alli todo bien .,incluso podes mirar los intentos que hice para que funcione ., te digo que seria eso ., y aparte la configuracion del TIMER ., estube buscando pero no encontre la configuracion del TON y TOFF en las librrias de arduino​
de las 16 funciones que tiene tanto en eje X e Y ., solo probaria con las cuatro indicadas el el WHILE​
porque una vez que arranque., tengo que probar los driver y las bobinas ., yo ya tengo el montaje armado.​
pero tengo que ver ., si sirve o se muere en el intento (las salidas) ., al uC no cro que le pase nada​
porque mi idea es manejar la conbinciones ., de las 4 funciones de manera independiente ., con un "potenciometro virtual"., manejado a travez de la USART​
esa parte ya la tengo funcionando y recontra probada ., funciona muy bien​
bueno aca te pongo lo que hice ., re-defini los puertos en los array ., ya que los numeros no los reconoce el IDE y larga error ., son como 1000 lineas ., jajajajajajajajaja​
PHP:
  #include <avr/io.h>
  #include <stdint.h>
  #include <avr/interrupt.h>
  #include <util/delay.h>
  #include <stdio.h>

#define XTAL 8000000

#define delayMicroseconds(tON) _delay_us(2750);
#define delayMicroseconds(tOFF) _delay_us(250);

//#define digitalWrite
//enum {LOW=0, HIGH=1}state;
#define  HIGH=1
#define  LOW =0
//************ Programa principal MAIN ***********//
int main(void)
{
	cli();

int tON = 2750;  //declarar el tiempo alto del pulso
int tOFF = 250;  //declarar el tiempo bajo del pulso
// *** establecer valor de WHILE  ***//
enum {FALSE=0, TRUE=1};


//*** Inicialización pines / port ***// 
void init_pinouts(){ 

    DDRA=  0xFF;		// salidas bajas
    PORTA= 0;
   }


void digitalWrite(int PIN, int state){
   if(state){
      PORTA |=(1 << (PIN-3)); //(1<<PA0,0)|(1<<PA1,0)|(1<<PA2,0)|(1<<PA3,0)|(1<<PA4,0)|(1<<PA5,0)|(1<<PA6,0)|(1<<PA7,0);  ///(1 << (pin- 3));
   }
   else{
      PORTA &=~(1 << (PIN-3));//(1<<PA0,1)|(1<<PA1,1)|(1<<PA2,1)|(1<<PA3,1)|(1<<PA4,1)|(1<<PA5,1)|(1<<PA6,1)|(1<<PA7,1);//(1 << (pin-3));
   }
}

	sei();
while(1)	// bucle principal (LOOP)     
     
   {  

       
    
  
//void loop(){
  yplus4();
  xplus4();
  yplus4();
  xminus4();
  yminus4();
  xplus4();
  yminus4();
  xminus4();  
}          
//  void setup(){  //
//  pinMode(3=PA0, OUTPUT);
//  pinMode(4=PA1, OUTPUT);
//  pinMode(5=PA2, OUTPUT);
//  pinMode(6=PA3, OUTPUT);
//  pinMode(7=PA4, OUTPUT);
//  pinMode(8=PA5, OUTPUT);
//  pinMode(9=PA6, OUTPUT);
//  pinMode(10=PA7, OUTPUT);
}



void xplus16(){  // define función de 16 pasos positivos X 
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
}
     
void xplus15(){ //define función de 15 pasos positivos X 
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
}
 
void xplus14(){  //define función de 14 pasos positivos X 
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
}

void xplus13(){  // define función de 13 pasos positivos X 
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
}

void xplus12(){  // define función de 12 pasos positivos X 
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
}

void xplus11(){  // define función de 11 pasos positivos X 
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
}

void xplus10(){  //define función de 10 pasos positivos X  
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
}

void xplus9(){  //define función de 9 pasos positivos X 
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
}

void xplus8(){  // define función de 8 pasos positivos X 
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
}

void xplus7(){  // define función de 7 pasos positivos X 
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
}

void xplus6(){  // define función de 6 pasos positivos X 
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
}

void xplus5(){  //define función de 5 pasos positivos X 
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
}

void xplus4(){  // define función de 4 pasos positivos X 
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
}

void xplus3(){  // define función de 3 pasos positivos X 
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
}

void xplus2(){  // define función de 2 pasos positivos X  
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
}

void xplus1(){  // define función de 1 pasos positivos X 
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
}
  
void xminus16(){  // define función de 16 pasos negativos X
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
}   

void xminus15(){  // define función de 15 pasos negativos X
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
}

void xminus14(){  // define función de 14 pasos negativos X/
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
}

void xminus13(){  // define función de 13 pasos negativos X
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
}

void xminus12(){  // define función de 12 pasos negativos X
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
}

void xminus11(){  // define función de 11 pasos negativos X 
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
}

void xminus10(){  // define función de 10 pasos negativos X
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
}

void xminus9(){  // define función de 9 pasos negativos X
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
}

void xminus8(){  // define función de 8 pasos negativos X
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
}

void xminus7(){  // define función de 7 pasos negativos X
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
}

void xminus6(){  // define función de 6 pasos negativos X
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
}

void xminus5(){  // define función de 5 pasos negativos X
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
}

void xminus4(){  // define función de 4 pasos negativos X
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA0, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA0, LOW);
  delayMicroseconds(tOFF);
}

void xminus3(){  // define función de 3 pasos negativos X
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA1, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA1, LOW);
  delayMicroseconds(tOFF);
}

void xminus2(){  // define función de 2 pasos negativos X
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA2, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA2, LOW);
  delayMicroseconds(tOFF);
}

void xminus1(){  // define función de 1 pasos negativos X
  digitalWrite(PA3, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA3, LOW);
  delayMicroseconds(tOFF);
}
    
    
void yplus16(){
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
}

void yplus15(){
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
}
  
void yplus14(){
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
}

void yplus13(){
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
}

void yplus12(){
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
}

void yplus11(){
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
}

void yplus10(){
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
}

void yplus9(){
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
}

void yplus8(){
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
}

void yplus7(){
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
}

void yplus6(){
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
}

void yplus5(){
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
}

void yplus4(){
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
}

void yplus3(){
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
}

void yplus2(){
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
}

void yplus1(){
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
}    
    
void yminus16(){
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
}

void yminus15(){
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
}

void yminus14(){
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
}

void yminus13(){
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
}

void yminus12(){
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
}

void yminus11(){
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
}

void yminus10(){
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
}

void yminus9(){
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
}
 
void yminus8(){
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
}

void yminus7(){
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
}

void yminus6(){
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
}

void yminus5(){
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
}

void yminus4(){
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA4, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA4, LOW);
  delayMicroseconds(tOFF);
}

void yminus3(){
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA5, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA5, LOW);
  delayMicroseconds(tOFF);
}

void yminus2(){
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
  digitalWrite(PA6, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA6, LOW);
  delayMicroseconds(tOFF);
}

void yminus1(){
  digitalWrite(PA7, HIGH);
  delayMicroseconds(tON);
  digitalWrite(PA7, LOW);
  delayMicroseconds(tOFF);
}
Jajaja, esta bien, si te dan limones haz limonada... :D



Guau.... eso es un montón de código para las funciones de pasos... se puede simplificar bastante, ejemplo para el eje X:

PHP:
#define TAMANO_SECUENCIA 4

unsigned int ObtenerPinProximoPaso( unsigned int pasoActual, 
   unsigned int adelante) {
  if(adelante) {
    pasoActual++;
    if (pasoActual >= TAMANO_SECUENCIA) {
      pasoActual = 0;
    }
  } else {
    if (pasoActual == 0) {
      pasoActual = TAMANO_SECUENCIA - 1;
    } else {
      pasoActual--;
    }
  }
  return pasoActual;
}

const unsigned int secuenciaPasosX[TAMANO_SECUENCIA] = {3,4,5,6};
unsigned int pasoActualX = 0;

void PasosX(int cuenta){
  unsigned int direccion, i;

  if(cuenta >= 0) {
    direccion = 1;
  } else {
    direccion = 0;
    cuenta = -cuenta;
  }
  
  for ( i = 0 ; i < cuenta ; --i ) {
    pasoActualX = ObtenerPinProximoPaso(pasoActualX, direccion);
    digitalWrite( secuenciaPasosX[pasoActualX] , HIGH );
    delayMicroseconds(tON);
    digitalWrite( secuenciaPasosX[pasoActualX] , LOW);
    delayMicroseconds(tOFF);
  }
}
Similar para el eje Y... aunque tampoco haría falta funciones distintas para los ejes X e Y, solo pasar un puntero más que sería al array secuenciaPasosX o secuenciaPasosY, más paso actual, más cuenta de pasos.
Ojo no probé nada del código de arriba, es solo para hablar del concepto.
Saludos.
querido amigo Ardogan ., !!!! que facilidad para escribir codigo ¡¡¡¡¡​
si eso es mas o menos lo que hace el otro codigo que te dije ., y aqui lo pongo para que veas​
pero como dije yo lo vi mas dificil de traspasar en mi caso​
incluso tiene posiscionamiento de inicio optico ., y por lo que vi funciona mejor que el otro (el que estoy pasando a C)​
creo que por el manejo de los puertos ., que se hace mas rapido ., y eso es una ventaja ., y digo creo no lo se ., talvez este sea como lo pensaste vos o te sea mas facil para pasar a C​
aparte usa como driver el L293D ., que como usa una placa de esas comerciales ., ya me pierde las funciones (librria aparte)​
PHP:
#include <AFMotor.h>

boolean debug = true;

int sensorPin = 14;
int laserPin = 13;
int buttonPin = 19;
int switchPin = 17;
int rLEDPin = 2;
int gLEDPin = 9;
int bLEDPin = 10;

AF_Stepper x(24, 2);
AF_Stepper y(24, 1);
static int METHOD = INTERLEAVE;

boolean laserPower;
boolean xPower;
boolean yPower;
boolean standby = true;
boolean calibrated;

int xres = 27;
int xmres = 27;
int yres = 10;
int ymres = 10;

int xpos = 0;
int ypos = 0;
int xsize = 0;
int ysize = 0;
int xmsize = 0;
int ymsize = 0;
int pattern = 0;
int shape = 0;
boolean automode = false;

int sDot = 0;
int sHPlane1 = 1;
int sHPlane2 = 2;
int sHPlane3 = 3;
int sVPlane1 = 4;
int sVPlane2 = 5;
int sVPlane3 = 6;
int sHPlaneL = 7;
int sVPlaneL = 8;
int sSquare1 = 9;
int sSquare2 = 10;
int sSquare3 = 11;
int sSquare4 = 12;
int sSquare5 = 13;
int sSquareR = 14;
int sSmiley = 15;
int sPath = 16;
int sMan = 17;
int sHSweep = 18;
int sVSweep = 19;

int sVarPX = 0;
int sVarPY = 0;
int sVarSquareSize = 1;

int pStill = 0;
int pRandom = 1;
int pSweepX = 2;
int pSweepY = 3;

int tick = 0;
int pSpeed = 20;

int defaultSpeed = 500;
int delayTime = 0;

void setup() {
  calibrated = false;
  
  // Start serial connection
  Serial.begin(9600);
  Serial.println("Starting...");
  
  // Pin setup
  
  pinMode(rLEDPin, OUTPUT);
  pinMode(gLEDPin, OUTPUT);
  pinMode(bLEDPin, OUTPUT);
  
  int blinkI = 30;
  
  while(blinkI--) {
  rOn();
  delay(50);
  rOff();
  gOn();
  delay(50);
  gOff();
  bOn();
  delay(50);
  bOff();
  }
  rOn();

  pinMode(laserPin, OUTPUT); // Laser
  pinMode(sensorPin, INPUT); // Calibration sensor
  pinMode(buttonPin, INPUT);
  pinMode(switchPin, INPUT);
  
  // Initialise random
  randomSeed(analogRead(18));
  
  // Set up motors
  x.setSpeed(defaultSpeed);
  y.setSpeed(defaultSpeed);
  
  // Calibrate mirrors
  if (!switchRead() && calibrate()) {
    calibrated = true;
    Serial.println("Mirrors calibrated");
    rOff();
  } else {
    rOn();
    Serial.println("Could not calibrate mirrors");
    calibrated = false;
  }
  
  if (debug) {
    Serial.println("Entered debug mode");
    calibrated = true;
  }
  
  Serial.println("Ready");
}

boolean calibrate() {
  if (calibrated) {
    Serial.println("Already calibrated, not redoing!");
    return true;
  }
  
  Serial.println("Starting mirror calibration...");
  
  for (int xstep = 0; xstep < 133; xstep++) {
    moveRight(1);
    laserOn();
    if (checkSensor()) return true;
  }
  moveLeft(133);
  
  moveUp(21);
  if (checkSensor()) return true;
  
  for (int ystep = 0; ystep < 42; ystep++) {
    moveDown(1);
    for (int xstep = 0; xstep < 133; xstep++) {
      if (checkSensor()) return true;
      moveRight(1);
    }
    moveLeft(133);
  }
  
  return false;
}

boolean checkSensor() {
  laserOn();
  delay(15);
  if (readSensor() >= 113) {
    laserOff();
    moveLeft(106);
    xpos = 0;
    ypos = 0;
    int blinkI = 30;
    while (blinkI--) {
      laserOn();
      delay(50);
      laserOff();
      delay(50);
    }
    calibrated = true;
    rOff();
    return true;
  } else {
    laserOff();
    return false;
  }
}

void loop() {
  tick++;
  if (tick > 500) tick = 0;
  
  if (!standby) {
    if (!automode) serialHandler();
    if (automode) autoLoop();
    patternLoop();
    shapeLoop();
  }
  
  if (tick % 10 == 0) buttonLoop();
  //Serial.println(tick);
}

void buttonLoop() {
  if (calibrated) rOff();
  if (!standby && buttonRead()) {
    automode = !automode;
    if (automode) {
      bOn();
    }
    if (!automode) {
      bOff();
      pattern = 0;
      shape = 0;
      resetPosition();
    }
    delay(500);
  }
  if (switchRead()) {
    automode = false;
    bOff();
    standby = true;
    pattern = 0;
    shape = 0;
    resetPosition();
    laserOff();
    gOff();
    if (calibrated) rOff();
  } else {
    if (standby) laserOn();
    standby = false;
    if (calibrated == true) {
      gOn();
    }
    if (calibrated == false) calibrate();
  }
}

boolean buttonRead() {
  if (digitalRead(buttonPin) == HIGH) {
    return true;
  } else {
    return false;
  }
}

boolean switchRead() {
    if (digitalRead(switchPin) == HIGH) {
    return true;
  } else {
    return false;
  }
}


void releaseCoils() {
  x.release();
  y.release();
  xpos = 0;
  ypos = 0;
}

void rOn() {
  digitalWrite(rLEDPin, HIGH);
}

void gOn() {
  digitalWrite(gLEDPin, HIGH);
}

void bOn() {
  digitalWrite(bLEDPin, HIGH);
}

void rOff() {
  digitalWrite(rLEDPin, LOW);
}

void gOff() {
  digitalWrite(gLEDPin, LOW);
}

void bOff() {
  digitalWrite(bLEDPin, LOW);
}

void laserOn() {
  digitalWrite(laserPin, HIGH);
  laserPower = true;
}

void laserOff() {
  digitalWrite(laserPin, LOW);
  laserPower = false;
}

void laserToggle() {
  if (laserPower) {
    laserOff();
    Serial.println("Turning laser off");
  } else {
    laserOn();
    Serial.println("Turning laser on");
  }
}

int readSensor() {
  int sensorVal = analogRead(sensorPin);
  Serial.println(sensorVal);
  return sensorVal;
}

void stepX(int delta) {
  xpos += delta;
  if (delta > 0) {
    x.step(delta, BACKWARD, METHOD);
  }
  if (delta < 0) {
    x.step(0-delta, FORWARD, METHOD);
  }
}

void stepY(int delta) {
  ypos += delta;
  if (delta > 0) {
    y.step(delta, BACKWARD, METHOD);
  }
  if (delta < 0) {
    y.step(0-delta, FORWARD, METHOD);
  }
}

void moveLeft(int delta) {
  stepX(0-delta);
}

void moveRight(int delta) {
  stepX(delta);
}

void moveUp(int delta) {
  stepY(delta);
}

void moveDown(int delta) {
  stepY(0-delta);
}

void moveMulti(int deltax, int deltay) {
  moveX(deltax);
  moveY(deltay);
  /*while (deltax != 0 || deltay != 0) {
    if (deltax < 0) {
      stepX(-1);
      deltax++;
    }
    if (deltax > 0) {
      stepX(1);
      deltax--;
    }
    if (deltay < 0) {
      stepY(-1);
      deltay++;
    }
    if (deltay > 0) {
      stepY(1);
      deltay--;
    }
  }*/
  if (delayTime > 0) delay(delayTime);
}

void moveTo(int x, int y) {
  moveMulti(x-xpos, y-ypos);
}

void moveX(int delta) {
  stepX(delta);
}

void moveY(int delta) {
  stepY(delta);
}

void resetPosition() {
  moveTo(0, 0);
}

void autoLoop() {
  //Serial.println("Automode");
  if (tick == 0) {
    pattern = random(1, 3);
    shape = random(0, 20);
    if (shape == 17) pattern = 0;
    pSpeed = random(5, 20);
    if (shape == 7 || shape == 8) tick = 450;
    if (shape == 18 || shape == 19) tick = 492;
    if (shape == 15) tick = 350;
    if (shape == 17) tick = 300;
    Serial.print("Shape is now ");
    Serial.println(shape);
    Serial.print("Pattern is now ");
    Serial.println(pattern);
  }
}

void shapeLoop() {
  if (shape == sDot) {
    delay(10);
  }
  
  if (shape == sSquare1) {
    shapeSquare(1);
  }
  if (shape == sSquare2) {
    shapeSquare(2);
  }
  if (shape == sSquare3) {
    shapeSquare(3);
  }
  if (shape == sSquare4) {
    shapeSquare(4);
  }
  if (shape == sSquare5) {
    shapeSquare(5);
  }
  if (shape == sSquareR) {
    if (tick % pSpeed == 0) sVarSquareSize = random(1, 8);
    shapeSquare(sVarSquareSize);
  }
  
  if (shape == sHPlane1) {
    shapeHPlane(1);
  }
  if (shape == sHPlane2) {
    shapeHPlane(2);
  }
  if (shape == sHPlane3) {
    shapeHPlane(3);
  }
  
  if (shape == sVPlane1) {
    shapeVPlane(1);
  }
  if (shape == sVPlane2) {
    shapeVPlane(2);
  }
  if (shape == sVPlane3) {
    shapeVPlane(3);
  }
  
  if (shape == sHPlaneL) {
    shapeHPlaneL();
  }
  if (shape == sVPlaneL) {
    shapeVPlaneL();
  }
  
  if (shape == sSmiley) {
    shapeSmiley();
  }
  
  if (shape == sPath) {
    shapePath();
  }
  
  if (shape == sMan) {
    shapeMan();
  }
  
  if (shape == sHSweep) {
    shapeHSweep();
  }
  
  if (shape == sVSweep) {
    shapeVSweep();
  }
  
  
}

void patternLoop() {
  if (pattern == pStill) {
    
  }
  
  if (pattern == pRandom) {
    if (tick%pSpeed == 0) {
      int xmax = xres-xsize;
      int ymax = yres-ysize;
      int xmin = 0-xmres+xmsize;
      int ymin = 0-ymres+ymsize;
      int newX = random(xmin, xmax);
      int newY = random(ymin, ymax);
      laserOff();
      moveTo(newX, newY);
      laserOn();
    }
  }
  
  if (pattern == pSweepX) {
    if (tick%pSpeed == 0) {
      if (xpos+xsize >= xres) {
        laserOff();
        moveTo(0-xmres+xmsize, ypos);
        laserOn();
      } else {
        laserOff();
        moveTo(xpos+1, ypos);
        laserOn();
      }
    }
  }
  
  if (pattern == pSweepY) {
    if (tick%pSpeed == 0) {
      if (ypos+ysize >= yres) {
        laserOff();
        moveTo(xpos, 0-ymres+ymsize);
        laserOn();
      } else {
        laserOff();
        moveTo(xpos, ypos+1);
        laserOn();
      }
    }
  }
}

void serialHandler() {
  while (Serial.available() > 0) {
		// read the incoming byte:
		int incomingByte = Serial.read();

                if (incomingByte == 108) {
                  laserToggle();
                }
                
                if (incomingByte == 114) {
                  releaseCoils();
                }
                
                // Key up
                if (incomingByte == 65) {
                  moveUp(1);
                }
                
                // Key down
                if (incomingByte == 66) {
                  moveDown(1);
                }
                
                // Key right
                if (incomingByte == 67) {
                  moveRight(1);
                }
                
                // Key left
                if (incomingByte == 68) {
                  moveLeft(1);
                }
                
                if (incomingByte == 99) {
                  resetPosition();
                }
                
                if (incomingByte == 43) {
                  defaultSpeed += 10;
                  Serial.print("Speed is now: ");
                  Serial.println(defaultSpeed);
                  x.setSpeed(defaultSpeed);
                  y.setSpeed(defaultSpeed);
                }
                
                if (incomingByte == 45) {
                  defaultSpeed -= 10;
                  Serial.print("Speed is now: ");
                  Serial.println(defaultSpeed);
                  x.setSpeed(defaultSpeed);
                  y.setSpeed(defaultSpeed);
                }
                
                if (incomingByte == 166) {
                  delayTime++;
                  Serial.print("Delay is now: ");
                  Serial.println(delayTime);
                }
                
                if (incomingByte == 184) {
                  delayTime--;
                  Serial.print("Delay is now: ");
                  Serial.println(delayTime);
                }
                
                if (incomingByte == 103) {
                  xpos = 0;
                  ypos = 0;
                }
                
                if (incomingByte == 112) {
                  pattern++;
                  if (pattern > 3) pattern = 0;
                  Serial.print("Cycling pattern to ");
                  Serial.println(pattern);
                  //resetPosition();
                }
                
                if (incomingByte == 115) {
                  shape++;
                  if (shape > 19) shape = 0;
                  Serial.print("Cycling shape to ");
                  Serial.println(shape);
                  resetPosition();
                }
                
                if (incomingByte == 97) {
                  automode = true;
                }
                
                if (incomingByte == 106) {
                  readSensor();
                }
                
                //Serial.print("Position: x=");
                //Serial.print(xpos);
                //Serial.print(" y=");
                //Serial.println(ypos);
		Serial.println(incomingByte, DEC);
	}
}

// Shapes

void shapeHPlane(int size) {
  xsize = size;
  ysize = 0;
  xmsize = 0;
  ymsize = 0;
  moveTo(xpos+size, ypos);
  moveTo(xpos-size, ypos);
}

void shapeVPlane(int size) {
  xsize = 0;
  ysize = size;
  xmsize = 0;
  ymsize = 0;
  moveTo(xpos, ypos+size);
  moveTo(xpos, ypos-size);
}

void shapeHPlaneL() {
  xsize = 27;
  ysize = 0;
  xmsize = -27;
  ymsize = 0;
  moveTo(-27, ypos);
  moveTo(27, ypos);
}

void shapeVPlaneL() {
  xsize = 0;
  ysize = 8;
  xmsize = 0;
  ymsize = -12;
  moveTo(xpos, -12);
  moveTo(xpos, 8);
}

void shapeSquare(int size) {
  xsize = size;
  ysize = size;
  xmsize = size;
  ymsize = size;
  moveX(size);
  moveY(0-size);
  moveX(0-size);
  moveY(size);
}

void shapeSmiley() {
  moveX(5);
  moveY(-5);
  moveX(-5);
  moveY(5);
  
  laserOff();
  moveTo(xpos+1, ypos-1);
  laserOn();
  
  moveX(1);
  moveY(-1);
  moveX(-1);
  moveY(1);
  
  laserOff();
  moveTo(xpos+2, ypos);
  laserOn();
  
  moveX(1);
  moveY(-1);
  moveX(-1);
  moveY(1);

  laserOff();
  moveTo(xpos-2, ypos-2);
  laserOn();
  
  moveX(3);
  moveY(-1);
  moveX(-3);
  moveY(1);
  
  laserOff();
  moveTo(xpos-1, ypos+3);
  laserOn();
}

void shapePath() {
  if (tick % 3 == 0) {
    int dir = random(0,4);
    if (dir == 0) {
      sVarPX = 1;
      sVarPY = 0;
    }
    if (dir == 1) {
      sVarPX = -1;
      sVarPY = 0;
    }
    if (dir == 2) {
      sVarPX = 0;
      sVarPY = 1;
    }
    if (dir == 3) {
      sVarPX = 0;
      sVarPY = -1;
    }
  }
  
  moveX(sVarPX);
  moveY(sVarPY);
  
  if (xpos > xres || xpos < -xmres || ypos > yres || ypos < -ymres) { 
    moveTo(0,0);
  }
  //moveTo(xpos+sVarPX, ypos+sVarPY);
}

void shapeMan() {
  delayTime = 2;
  laserOn();
  moveX(2);
  moveY(2);
  moveX(-2);
  moveY(-2);
  laserOff();
  moveX(1);
  laserOn();
  moveY(-3);  
  laserOff();
  moveX(-1);
  moveY(-1);
  laserOn();
  moveY(1);
  moveX(2);
  moveY(-1);
  
  laserOff();
  
  if (tick % 6 > 2) {
    moveY(2);
    laserOn();
    moveY(1);
    moveX(-3);
  } else {
    moveX(1);
    moveY(3);
    laserOn();
    moveX(-3);
    moveY(-1);
  }
  
  laserOff();
  
  moveTo(0, 0);
  delayTime = 0;
}

void shapeHSweep() {
  laserOff();
  moveTo(-xmres, -ymres);
  laserOn();
  for (int i = 0; i <= yres; i++) {
    moveX(xres*2);
    moveY(1);
    moveX(-xres*2);
    moveY(1);
  }
  laserOff();
}

void shapeVSweep() {
  laserOff();
  moveTo(-xmres, -ymres);
  laserOn();
  for (int i = 0; i <= xres; i++) {
    moveY(yres*2);
    moveX(1);
    moveY(-yres*2);
    moveX(1);
  }
  laserOff();
}

void rotationTest() {
  while (1) {
    moveLeft(1);
    moveUp(1);
  }
}
bueno espero sus sugerencias y comentarios ., un gran abrazo a los dos​
 
#16
hola gente ., bueno pude pasr la libreria del arduino al AvrStudio​
gracias a las recomendaciones y ayuda de los compañeros del foro​
ahora entiendo un poco (no mucho) ., de como trabaja el IDE de arduino ., y desde el principio ., uno podria pensar que no podria funcionar​
el IDE de arduino., utiliza comandos prefijados ., en cuanto a las definiciones y funciones ., en el AVRstudio hay que armarlas o definirlas​
en mucho de eso ., te orienta las funcines declaradas en la pagina de arduino ., separdas y explicadas de acuerdo al uso​
lamentablemente ., no me entro toda la traduccion al AVRstudio ., (demaciado grande)., ya lo habia advertido NUYEL ., mas arriba y eso que uso el atmega8515 y no el atmega328p​
lo negativo ., es que tuve que re-escribir las 2834 lineas del codigo de nuevo (duro trabajo., de por lo mernos 14 Hs en varias tandas)​
probe varias maneras de redefinir las lineas ., pero algunas me las aceptaba el compilador y otras no​
entonces opte ., por usar las funciones que siempre me funcionaron ., obiamente copiando la idea original de funcionamiento ., pero planteada de manera distinta en el avrstudio​
una cosa que me llamo la atencion es que ., no hay error de pasos ., siempre queda donde empezo​
y mecaniacmente no hay nada limitando su recorrido ., la pueba fisica fue con dos circulos de carton pegados en el centro del eje y con una linea negra marcada ., desde el centro al borde ( radio)​
yo le habia colocado un alambrecito (fijo) ., indicando la coincidencia con la linea negra ., pero nunca se salieron de lugar por lo tanto siempre arrancaron en el mismo paso​
contando ., que tenian desplasamiento hacia la izquierda de la linea y hacia la derecha de ella tambien​
el timer0 lo declare ., nada mas para que tuviera estabilidad el crisrtal externo ., pero no cumple ninguna funcion en las librerias​
tambien viendo el comportamiento en lo fisico ., tomo en cuenta lo que dijo el compañero ANDROGAN ., el asunto es que yo pudiera manejar esos puntos que se definen con potenciometros virtuales (UART)​
y no como en este caso ( debido al tamaño) ., no pude implementar ., adjunto un dibujo en paint ., de como es esto​
lSCABER_X_Y.jpg
bueno yo lo que nesesito es poder deplazar ., un punto (por decirlo de alguna manera) ., desde el centro a los angulos de los bordes de cuadrado​
tambien adjunto el proyecto completo en AVRstudio por sialgien le sirve de guia​
y aca nuestro el .C como quedo
PHP:
  #include <avr/io.h>
  #include <stdint.h>
  #include <avr/interrupt.h>
  #include <util/delay.h>
  #include <stdio.h>
  #include "lib_X_Y.h"


#define XTAL 8000000


//************ Programa principal MAIN ***********//
int main(void)
{
	cli();




// Inicializar Puertos 
 void Init_X_Y_port( void )
 {
  
  DDR_COIL1 |= (1<<PIN_COIL1);
  DDR_COIL2 |= (1<<PIN_COIL2);
  DDR_COIL3 |= (1<<PIN_COIL3);
  DDR_COIL4 |= (1<<PIN_COIL4);
  DDR_COIL5 |= (1<<PIN_COIL5);
  DDR_COIL6 |= (1<<PIN_COIL6);
  DDR_COIL7 |= (1<<PIN_COIL7);
  DDR_COIL8 |= (1<<PIN_COIL8);
  
   
 }

// ***** inicializacion del timer****//
void init_timer(){
		TCCR0|=(1<<CS02)|(1<<CS00); //TCCR0|= (1<<CS02);	// Precontador 256
		TIMSK|=(1<<TOIE0);	// desbordamientos de la interrupción
			
}



   
   // init_timer();	// Establecer el temporizador
    Init_X_Y_port();// inizialisa las salidas  
   
	sei();

    for(;;)
	   {
       
    
  
//****** inicia funcion 4 solamente ******//
       yplus4();
       xplus4();
       yplus4();
      xminus4();
      yminus4();
       xplus4();
      yminus4();
      xminus4();  
       yplus16();
       xplus16();
       yplus16();
      xminus16();
      yminus16();
       xplus16();
      yminus16();
      xminus16();     




 
     }          
 
	};

void xplus4(void){  // define función de 4 pasos positivos X 
  PRT_COIL1 |=  (1<<PIN_COIL1);
  _delay_us(2750);
  PRT_COIL1 &= ~(1<<PIN_COIL1);
  _delay_us(250);
  PRT_COIL2 |=  (1<<PIN_COIL2);
  _delay_us(2750);
  PRT_COIL2 &= ~(1<<PIN_COIL2);
  _delay_us(250);
  PRT_COIL3 |=  (1<<PIN_COIL3);
  _delay_us(2750);
  PRT_COIL3 &= ~(1<<PIN_COIL3);
  _delay_us(250);
  PRT_COIL4 |=  (1<<PIN_COIL4);
  _delay_us(2750);
  PRT_COIL4 &= ~(1<<PIN_COIL4);
  _delay_us(250);

}

void xminus4(void){  // define función de 4 pasos negativos X
  PRT_COIL4 |=  (1<<PIN_COIL4);
  _delay_us(2750);
  PRT_COIL4 &= ~(1<<PIN_COIL4);
  _delay_us(250);
  PRT_COIL3 |=  (1<<PIN_COIL3);
  _delay_us(2750);
  PRT_COIL3 &= ~(1<<PIN_COIL3);
  _delay_us(250);
  PRT_COIL2 |=  (1<<PIN_COIL2);
  _delay_us(2750);
  PRT_COIL2 &= ~(1<<PIN_COIL2);
  _delay_us(250);
  PRT_COIL1 |=  (1<<PIN_COIL1);
  _delay_us(2750);
  PRT_COIL1 &= ~(1<<PIN_COIL1);
  _delay_us(250);
}



void yplus4(void){
  PRT_COIL5 |=  (1<<PIN_COIL5);
  _delay_us(2750);
  PRT_COIL5 &= ~(1<<PIN_COIL5);
  _delay_us(250);
  PRT_COIL6 |=  (1<<PIN_COIL6);
  _delay_us(2750);
  PRT_COIL6 &= ~(1<<PIN_COIL6);
  _delay_us(250);
  PRT_COIL7 |=  (1<<PIN_COIL7);
  _delay_us(2750);
  PRT_COIL7 &= ~(1<<PIN_COIL7);
  _delay_us(250);
  PRT_COIL8 |=  (1<<PIN_COIL8);
  _delay_us(2750);
  PRT_COIL8 &= ~(1<<PIN_COIL8);
  _delay_us(250);
}


void yminus4(void){
  PRT_COIL8 |=  (1<<PIN_COIL8);
  _delay_us(2750);
  PRT_COIL8 &= ~(1<<PIN_COIL8);
  _delay_us(250);
  PRT_COIL7 |=  (1<<PIN_COIL7);
  _delay_us(2750);
  PRT_COIL7 &= ~(1<<PIN_COIL7);
  _delay_us(250);
  PRT_COIL6 |=  (1<<PIN_COIL6);
  _delay_us(2750);
  PRT_COIL6 &= ~(1<<PIN_COIL6);
  _delay_us(250);
  PRT_COIL5 |=  (1<<PIN_COIL5);
  _delay_us(2750);
  PRT_COIL5 &= ~(1<<PIN_COIL5);
  _delay_us(250);
}

 void xplus16(void){  // define función de 16 pasos positivos X 
  PRT_COIL1 |=  (1<<PIN_COIL1);
  _delay_us(2750);
  PRT_COIL1 &= ~(1<<PIN_COIL1);
  _delay_us(250);
  PRT_COIL2 |=  (1<<PIN_COIL2);
  _delay_us(2750);
  PRT_COIL2 &= ~(1<<PIN_COIL2);
  _delay_us(250);
  PRT_COIL3 |=  (1<<PIN_COIL3);
  _delay_us(2750);
  PRT_COIL3 &= ~(1<<PIN_COIL3);
  _delay_us(250);
  PRT_COIL4 |=  (1<<PIN_COIL4);
  _delay_us(2750);
  PRT_COIL4 &= ~(1<<PIN_COIL4);
  _delay_us(250);
  PRT_COIL1 |=  (1<<PIN_COIL1);
  _delay_us(2750);
  PRT_COIL1 &= ~(1<<PIN_COIL1); 
  _delay_us(250);
  PRT_COIL2 |=  (1<<PIN_COIL2);
  _delay_us(2750);
  PRT_COIL2 &= ~(1<<PIN_COIL2);
  _delay_us(250);
  PRT_COIL3 |=  (1<<PIN_COIL3);
  _delay_us(2750);
  PRT_COIL3 &= ~(1<<PIN_COIL3);
  _delay_us(250);
  PRT_COIL4 |=  (1<<PIN_COIL4);
  _delay_us(2750);
  PRT_COIL4 &= ~(1<<PIN_COIL4);
  _delay_us(250);
  PRT_COIL1 |=  (1<<PIN_COIL1);
  _delay_us(2750);
  PRT_COIL1 &= ~(1<<PIN_COIL1);
  _delay_us(250);
  PRT_COIL2 |=  (1<<PIN_COIL2);
  _delay_us(2750);
  PRT_COIL2 &= ~(1<<PIN_COIL2);
  _delay_us(250);
  PRT_COIL3 |=  (1<<PIN_COIL3);
  _delay_us(2750);
  PRT_COIL3 &= ~(1<<PIN_COIL3);
  _delay_us(250);
  PRT_COIL4 |=  (1<<PIN_COIL4);
  _delay_us(2750);
  PRT_COIL4 &= ~(1<<PIN_COIL4);
  _delay_us(250);
  PRT_COIL1 |=  (1<<PIN_COIL1);
  _delay_us(2750);
  PRT_COIL1 &= ~(1<<PIN_COIL1);
  _delay_us(250);
  PRT_COIL2 |=  (1<<PIN_COIL2);
  _delay_us(2750);
  PRT_COIL2 &= ~(1<<PIN_COIL2);
  _delay_us(250);
  PRT_COIL3 |=  (1<<PIN_COIL3);
  _delay_us(2750);
  PRT_COIL3 &= ~(1<<PIN_COIL3);
  _delay_us(250);
  PRT_COIL4 |=  (1<<PIN_COIL4);
  _delay_us(2750);
  PRT_COIL4 &= ~(1<<PIN_COIL4);
  _delay_us(250);
}    


void xminus16(void){  // define función de 16 pasos negativos X
  PRT_COIL4 |=  (1<<PIN_COIL4);
  _delay_us(2750);
  PRT_COIL4 &= ~(1<<PIN_COIL4);
  _delay_us(250);
  PRT_COIL3 |=  (1<<PIN_COIL3);
  _delay_us(2750);
  PRT_COIL3 &= ~(1<<PIN_COIL3);
  _delay_us(250);
  PRT_COIL2 |=  (1<<PIN_COIL2);
  _delay_us(2750);
  PRT_COIL2 &= ~(1<<PIN_COIL2);
  _delay_us(250);
  PRT_COIL1 |=  (1<<PIN_COIL1);
  _delay_us(2750);
  PRT_COIL1 &= ~(1<<PIN_COIL1);
  _delay_us(250);
  PRT_COIL4 |=  (1<<PIN_COIL4);
  _delay_us(2750);
  PRT_COIL4 &= ~(1<<PIN_COIL4);
  _delay_us(250);
  PRT_COIL3 |=  (1<<PIN_COIL3);
  _delay_us(2750);
  PRT_COIL3 &= ~(1<<PIN_COIL3);
  _delay_us(250);
  PRT_COIL2 |=  (1<<PIN_COIL2);
  _delay_us(2750);
  PRT_COIL2 &= ~(1<<PIN_COIL2);
  _delay_us(250);
  PRT_COIL1 |=  (1<<PIN_COIL1);
  _delay_us(2750);
  PRT_COIL1 &= ~(1<<PIN_COIL1);
  _delay_us(250);
  PRT_COIL4 |=  (1<<PIN_COIL4);
  _delay_us(2750);
  PRT_COIL4 &= ~(1<<PIN_COIL4);
  _delay_us(250);
  PRT_COIL3 |=  (1<<PIN_COIL3);
  _delay_us(2750);
  PRT_COIL3 &= ~(1<<PIN_COIL3);
  _delay_us(250);
  PRT_COIL2 |=  (1<<PIN_COIL2);
  _delay_us(2750);
  PRT_COIL2 &= ~(1<<PIN_COIL2);
  _delay_us(250);
  PRT_COIL1 |=  (1<<PIN_COIL1);
  _delay_us(2750);
  PRT_COIL1 &= ~(1<<PIN_COIL1);
  _delay_us(250);
  PRT_COIL4 |=  (1<<PIN_COIL4);
  _delay_us(2750);
  PRT_COIL4 &= ~(1<<PIN_COIL4);
  _delay_us(250);
  PRT_COIL3 |=  (1<<PIN_COIL3);
  _delay_us(2750);
  PRT_COIL3 &= ~(1<<PIN_COIL3);
  _delay_us(250);
  PRT_COIL2 |=  (1<<PIN_COIL2);
  _delay_us(2750);
  PRT_COIL2 &= ~(1<<PIN_COIL2);
  _delay_us(250);
  PRT_COIL1 |=  (1<<PIN_COIL1);
  _delay_us(2750);
  PRT_COIL1 &= ~(1<<PIN_COIL1);
  _delay_us(250);
}    
void yplus16(void){
  PRT_COIL5 |=  (1<<PIN_COIL5);
  _delay_us(2750);
  PRT_COIL5 &= ~(1<<PIN_COIL5);
  _delay_us(250);
  PRT_COIL6 |=  (1<<PIN_COIL6);
  _delay_us(2750);
  PRT_COIL6 &= ~(1<<PIN_COIL6);
  _delay_us(250);
  PRT_COIL7 |=  (1<<PIN_COIL7);
  _delay_us(2750);
  PRT_COIL7 &= ~(1<<PIN_COIL7);
  _delay_us(250);
  PRT_COIL8 |=  (1<<PIN_COIL8);
  _delay_us(2750);
  PRT_COIL8 &= ~(1<<PIN_COIL8);
  _delay_us(250);
  PRT_COIL5 |=  (1<<PIN_COIL5);
  _delay_us(2750);
  PRT_COIL5 &= ~(1<<PIN_COIL5);
  _delay_us(250);
  PRT_COIL6 |=  (1<<PIN_COIL6);
  _delay_us(2750);
  PRT_COIL6 &= ~(1<<PIN_COIL6);
  _delay_us(250);
  PRT_COIL7 |=  (1<<PIN_COIL7);
  _delay_us(2750);
  PRT_COIL7 &= ~(1<<PIN_COIL7);
  _delay_us(250);
  PRT_COIL8 |=  (1<<PIN_COIL8);
  _delay_us(2750);
  PRT_COIL8 &= ~(1<<PIN_COIL8);
  _delay_us(250);
  PRT_COIL5 |=  (1<<PIN_COIL5);
  _delay_us(2750);
  PRT_COIL5 &= ~(1<<PIN_COIL5);
  _delay_us(250);
  PRT_COIL6 |=  (1<<PIN_COIL6);
  _delay_us(2750);
  PRT_COIL6 &= ~(1<<PIN_COIL6);
  _delay_us(250);
  PRT_COIL7 |=  (1<<PIN_COIL7);
  _delay_us(2750);
  PRT_COIL7 &= ~(1<<PIN_COIL7);
  _delay_us(250);
  PRT_COIL8 |=  (1<<PIN_COIL8);
  _delay_us(2750);
  PRT_COIL8 &= ~(1<<PIN_COIL8);
  _delay_us(250);
  PRT_COIL5 |=  (1<<PIN_COIL5);
  _delay_us(2750);
  PRT_COIL5 &= ~(1<<PIN_COIL5);
  _delay_us(250);
  PRT_COIL6 |=  (1<<PIN_COIL6);
  _delay_us(2750);
  PRT_COIL6 &= ~(1<<PIN_COIL6);
  _delay_us(250);
  PRT_COIL7 |=  (1<<PIN_COIL7);
  _delay_us(2750);
  PRT_COIL7 &= ~(1<<PIN_COIL7);
  _delay_us(250);
  PRT_COIL8 |=  (1<<PIN_COIL8);
  _delay_us(2750);
  PRT_COIL8 &= ~(1<<PIN_COIL8);
  _delay_us(250);
}

void yminus16(void){
  PRT_COIL8 |=  (1<<PIN_COIL8);
  _delay_us(2750);
  PRT_COIL8 &= ~(1<<PIN_COIL8);
  _delay_us(250);
  PRT_COIL7 |=  (1<<PIN_COIL7);
  _delay_us(2750);
  PRT_COIL7 &= ~(1<<PIN_COIL7);
  _delay_us(250);
  PRT_COIL6 |=  (1<<PIN_COIL6);
  _delay_us(2750);
  PRT_COIL6 &= ~(1<<PIN_COIL6);
  _delay_us(250);
  PRT_COIL5 |=  (1<<PIN_COIL5);
  _delay_us(2750);
  PRT_COIL5 &= ~(1<<PIN_COIL5);
  _delay_us(250);
  PRT_COIL8 |=  (1<<PIN_COIL8);
  ;_delay_us(2750);
  PRT_COIL8 &= ~(1<<PIN_COIL8);
  _delay_us(250);
  PRT_COIL7 |=  (1<<PIN_COIL7);
  _delay_us(2750);
  PRT_COIL7 &= ~(1<<PIN_COIL7);
  _delay_us(250);
  PRT_COIL6 |=  (1<<PIN_COIL6);
  _delay_us(2750);
  PRT_COIL6 &= ~(1<<PIN_COIL6);
  _delay_us(250);
  PRT_COIL5 |=  (1<<PIN_COIL5);
  _delay_us(2750);
  PRT_COIL5 &= ~(1<<PIN_COIL5);
  _delay_us(250);
  PRT_COIL8 |=  (1<<PIN_COIL8);
  _delay_us(2750);
  PRT_COIL8 &= ~(1<<PIN_COIL8);
  _delay_us(250);
  PRT_COIL7 |=  (1<<PIN_COIL7);
  _delay_us(2750);
  PRT_COIL7 &= ~(1<<PIN_COIL7);
  _delay_us(250);
  PRT_COIL6 |=  (1<<PIN_COIL6);
  _delay_us(2750);
  PRT_COIL6 &= ~(1<<PIN_COIL6);
  _delay_us(250);
  PRT_COIL5 |=  (1<<PIN_COIL5);
  _delay_us(2750);
  PRT_COIL5 &= ~(1<<PIN_COIL5);
  _delay_us(250);
  PRT_COIL8 |=  (1<<PIN_COIL8);
  _delay_us(2750);
  PRT_COIL8 &= ~(1<<PIN_COIL8);
  _delay_us(250);
  PRT_COIL7 |=  (1<<PIN_COIL7);
  _delay_us(2750);
  PRT_COIL7 &= ~(1<<PIN_COIL7);
  _delay_us(250);
  PRT_COIL6 |=  (1<<PIN_COIL6);
  _delay_us(2750);
  PRT_COIL6 &= ~(1<<PIN_COIL6);
  _delay_us(250);
  PRT_COIL5 |=  (1<<PIN_COIL5);
  _delay_us(2750);
  PRT_COIL5 &= ~(1<<PIN_COIL5);
  _delay_us(250);
}
bueno espero sus comentarios e ideas :apreton:
 

Adjuntos

#17
...
lo negativo ., es que tuve que re-escribir las 2834 lineas del codigo de nuevo (duro trabajo., de por lo mernos 14 Hs en varias tandas)
probe varias maneras de redefinir las lineas ., pero algunas me las aceptaba el compilador y otras no

Epa!!!, sí, el Arduino mete un choclo de código importante para aparentar sencillez hacia el usuario, pero eso tiene un costo.
Además es código para una plataforma/framework, y como tal tiene que separar muy bien hardware (cualquier cosa que toque un registro del micro) de servicios (librerías stepper, botones, LCD, etc). Y el código seguramente tiene #if o #ifdef por todas partes para contemplar el uso de múltiples procesadores con sus opciones (clock, periféricos, etc).

entonces opte ., por usar las funciones que siempre me funcionaron ., obiamente copiando la idea original de funcionamiento ., pero planteada de manera distinta en el avrstudio​
una cosa que me llamo la atencion es que ., no hay error de pasos ., siempre queda donde empezo
y mecaniacmente no hay nada limitando su recorrido ., la pueba fisica fue con dos circulos de carton pegados en el centro del eje y con una linea negra marcada ., desde el centro al borde ( radio)​
yo le habia colocado un alambrecito (fijo) ., indicando la coincidencia con la linea negra ., pero nunca se salieron de lugar por lo tanto siempre arrancaron en el mismo paso​
contando ., que tenian desplasamiento hacia la izquierda de la linea y hacia la derecha de ella tambien


Sí, pienso que a la larga el arduino va imponer una interfaz estandar hacia las funciones de micros (como poner un pin en alto/bajo, como entrada/salida, como usar un puerto serie, y - Dios nos libre - como usar un stack TCP/IP) (los nombres de las funciones y como llamarlas, no lo que hacen específicamente las funciones).

En cuanto a los pasos, no deberías tener pérdida de pasos si la corriente del stepper está bien regulada de acuerdo a la carga mecánica acoplada al eje. Se pierden pasos cuando no se envía corriente suficiente al motor, y esa corriente depende de la velocidad (hay que respetar la curva de torque).
Nunca es mala idea tener por lo menos 1 forma de marcar el "home" del motor, con un sensor independiente. Por más que no sea nada preciso (no digo poner un encoder), solo para detectar de que algo salió mal y tener la oportunidad de remediarlo en forma automática en forma grosera (luego el que quiera precisión de 1 paso, que calibre).

el timer0 lo declare ., nada mas para que tuviera estabilidad el crisrtal externo ., pero no cumple ninguna funcion en las librerias​
tambien viendo el comportamiento en lo fisico ., tomo en cuenta lo que dijo el compañero ANDROGAN ., el asunto es que yo pudiera manejar esos puntos que se definen con potenciometros virtuales (UART)​
y no como en este caso ( debido al tamaño) ., no pude implementar ., adjunto un dibujo en paint ., de como es esto
bueno yo lo que nesesito es poder deplazar ., un punto (por decirlo de alguna manera) ., desde el centro a los angulos de los bordes de cuadrado


Mmmm, no termino de entender bien que es lo que precisas.
Te gustaría tener una función tipo:
pasos(eje, direccion, cuenta);
eje = eje X o eje Y
direccion = adelante o atras
cuenta = cantidad de pasos a realizar

o quizás estás hablando de algo como
mover(ejex, ejey);
ejex: cantidad de pasos en el eje x, positivo o negativo
ejey: similar anterior

u otra alternativa?.
No entiendo bien eso de potenciómetros UART... quiere decir que desde la PC se envía un valor que especifica la posición deseada?, o el movimiento deseado a partir del actual?, o el valor de ejeX y ejeY que debe mantener el móvil (setpoint).

Releo... a ver si es algo así: querés pasarle por UART un par de coordenadas (X,Y) en una grilla de 32x32 (16 positivo y 16 negativo, quiero decir, x e y = -16 a +16) posiciones predefinidas en algún lugar.
¿Es así?

... como quedo ... bueno espero sus comentarios e ideas :apreton:

Ok, en el código veo las funciones para mover (incrementalmente/en forma relativa) los motores una cantidad fija de pasos en uno u otro eje.
Mi pregunta es: ¿como querés decirle al Arduino/Atmega qué movimientos tiene que realizar? (uart?, botones, presets) o quizás realiza un patrón de movimiento fijo y nada más?.
 
#18
Curioso que no aceptara las funciones, eran traducciones bastante simples que debían ser tomadas por cualquier compilador (y en cualquier lenguaje) a cualquier MCU que se escribiera con acceso directo a registros.

Siempre que veo los códigos que publican para el AVR Studio veo que mucho lo manejan directamente a registros, igual estoy acostumbrado ya que usando los MSP430 lo hago de la misma manera, lo que siempre me parece incomodo es el hacer 1<<BIT_DEL_REGISTRO para modificar un bit, veo que tienen marcados el bit del registro como desplazamiento, en mi caso los header usan valores hexadecimales así que si es el BIT7 es 0x80 en lugar de 7, todo se reduce a simplemente escribir REGISTRO = BITn
 
#19
hola ., y muchisimas gracias amigos ., por su tiempo e ideas
Epa!!!, sí, el Arduino mete un choclo de código importante para aparentar sencillez hacia el usuario, pero eso tiene un costo.
Además es código para una plataforma/framework, y como tal tiene que separar muy bien hardware (cualquier cosa que toque un registro del micro) de servicios (librerías stepper, botones, LCD, etc). Y el código seguramente tiene #if o #ifdef por todas partes para contemplar el uso de múltiples procesadores con sus opciones (clock, periféricos, etc)
claro amigo ., ese es el problema que tuve​
!!!! hacer trabajo detectivesco ¡¡¡¡ ., o sea ver la funcion o declaracion en el IDE de ARDUINO ., y seguirla ., internamente en el compilador y de alli ver que es lo mismo en el AVRstudio​
pero se puede ., al menos en libtrerias sencillas., el otro ejemplo trabaja con un "sketch" y libreria aparte​

Sí, pienso que a la larga el arduino va imponer una interfaz estandar hacia las funciones de micros (como poner un pin en alto/bajo, como entrada/salida, como usar un puerto serie, y - Dios nos libre - como usar un stack TCP/IP) (los nombres de las funciones y como llamarlas, no lo que hacen específicamente las funciones).

En cuanto a los pasos, no deberías tener pérdida de pasos si la corriente del stepper está bien regulada de acuerdo a la carga mecánica acoplada al eje. Se pierden pasos cuando no se envía corriente suficiente al motor, y esa corriente depende de la velocidad (hay que respetar la curva de torque).
Nunca es mala idea tener por lo menos 1 forma de marcar el "home" del motor, con un sensor independiente. Por más que no sea nada preciso (no digo poner un encoder), solo para detectar de que algo salió mal y tener la oportunidad de remediarlo en forma automática en forma grosera (luego el que quiera precisión de 1 paso, que calibre)
bueno con respecto a eso yo creo ., que van para el otro lado ., al integrar la interfaz del arduino en el AVRstudio​
pienso que despues seguiran con una funcion de "traspaso"​
del proyecto hecho con ARDUINO se pase al AVRstudio ., sin estos problemas ., basicamente se podria ., algo de eso se empezo en avrfreak​
es una manera de expandir la plataforma de desarrollo ., por ejemplo el arduino 2560 se puede usar sin nesesidad de otra cosa que el avrstudio y el programador AVRdude​
y en la placa te quedan 98 puertos libres (tenes que conectar el VCC y GND) pero por lo demas es como cualquier micro​
en cuanto a los pasos y el sensor de inico ., ya rengo algo hecho ., y me funciona bien​
solo habria que tener en cuenta que iria al inciarce el micro ., como desis vos en caso de asegurar una posiscion de inicio​
aca tenes como lo hago
PHP:
volatile uint16_t Ist1 = 0;
volatile uint16_t Soll1 = 0;
volatile uint8_t Step1 = 0;

//Funciones privadas 
void SetPort( uint8_t value );
void MakeStep( uint8_t direction );

// Inicializar Puertos y fijar la rueda a la posición cero
extern void Init_cero_steep( void )
 {
  int i;
  DDR_COIL1 |= (1<<PIN_COIL1);
  DDR_COIL2 |= (1<<PIN_COIL2);
  DDR_COIL3 |= (1<<PIN_COIL3);
  DDR_COIL4 |= (1<<PIN_COIL4);
  DDR_SENSOR &= ~(1<<PIN_SENSOR);

  for(i=0; i<=8; i++)// Asegúrese de que la posición del motor se ajusta
   {
    MakeStep(1);
   }
  for(i=0; i<=(MOT_STEPS/2); i++)// Si el pin sensor está a nivel bajo, gire la rueda de gobos
   {						// hasta que el sensor está fuera de posición cero.
    if((PR_SENSOR & (1<<PIN_SENSOR))) break;
    MakeStep(1);
    MakeStep(1);
    _delay_ms(4);
   }
  for(i=0; i<=MOT_STEPS; i++)//Ahora busca la posición cero de nuevo!
   {
    MakeStep(0);
    MakeStep(0);
    _delay_ms(4);
    if(!(PR_SENSOR & (1<<PIN_SENSOR))) break;
   }
  for(i=0; i<=CORR_VAL; i++)//posición correcta con valor fijo si es necesario
   {
    MakeStep(CORR_DIR);
   }
 }
//Paso el motor en dirección definida
void MakeStep( uint8_t direction )
 {
  if(direction==0) 
   {
    Step1++;
    if(Step1>=8) Step1=0;
   } else {
    if(Step1==0) Step1=8;
    Step1--;
   }
  SetPort(Step1);
  _delay_ms(4);
 }


// Conmutar los puertos
void SetPort( uint8_t value )
 {
  switch(value) 
   {
    case 0:
     PRT_COIL1 |=  (1<<PIN_COIL1);
     PRT_COIL2 &= ~(1<<PIN_COIL2);
     PRT_COIL3 &= ~(1<<PIN_COIL3);
     PRT_COIL4 &= ~(1<<PIN_COIL4);
     break; 
    case 1:
     PRT_COIL1 |=  (1<<PIN_COIL1);
     PRT_COIL2 |=  (1<<PIN_COIL2);
     PRT_COIL3 &= ~(1<<PIN_COIL3);
     PRT_COIL4 &= ~(1<<PIN_COIL4);
     break;    
    case 2:
     PRT_COIL1 &= ~(1<<PIN_COIL1);
     PRT_COIL2 |=  (1<<PIN_COIL2);
     PRT_COIL3 &= ~(1<<PIN_COIL3);
     PRT_COIL4 &= ~(1<<PIN_COIL4);
     break;
    case 3:
     PRT_COIL1 &= ~(1<<PIN_COIL1);
     PRT_COIL2 |=  (1<<PIN_COIL2);
     PRT_COIL3 |=  (1<<PIN_COIL3);
     PRT_COIL4 &= ~(1<<PIN_COIL4);
     break; 
    case 4:
     PRT_COIL1 &= ~(1<<PIN_COIL1);
     PRT_COIL2 &= ~(1<<PIN_COIL2);
     PRT_COIL3 |=  (1<<PIN_COIL3);
     PRT_COIL4 &= ~(1<<PIN_COIL4);
     break;
    case 5:
     PRT_COIL1 &= ~(1<<PIN_COIL1);
     PRT_COIL2 &= ~(1<<PIN_COIL2);
     PRT_COIL3 |=  (1<<PIN_COIL3);
     PRT_COIL4 |=  (1<<PIN_COIL4);
     break; 
    case 6:
     PRT_COIL1 &= ~(1<<PIN_COIL1);
     PRT_COIL2 &= ~(1<<PIN_COIL2);
     PRT_COIL3 &= ~(1<<PIN_COIL3);
     PRT_COIL4 |=  (1<<PIN_COIL4);
     break;
    case 7:
     PRT_COIL1 |=  (1<<PIN_COIL1);
     PRT_COIL2 &= ~(1<<PIN_COIL2);
     PRT_COIL3 &= ~(1<<PIN_COIL3);
     PRT_COIL4 |=  (1<<PIN_COIL4);
     break; 
   }
 }
esto es simple ., sobre un giro de 360° ., y se coloca un circulo asociado al eje (carton ., chapa ., plastico ., ETC)​
y se le hace una pequeña ranura ., con un interuptor opctico (de ranura tambien) se detecta esa ranura ., y manda el pin del micro a GND (sensor)​
y te puedo asegurar que no falla nunca ., aparet de ser rapidisimo​
Mmmm, no termino de entender bien que es lo que precisas.
Te gustaría tener una función tipo:
pasos(eje, direccion, cuenta);
eje = eje X o eje Y
direccion = adelante o atras
cuenta = cantidad de pasos a realizar

o quizás estás hablando de algo como
mover(ejex, ejey);
ejex: cantidad de pasos en el eje x, positivo o negativo
ejey: similar anterior

u otra alternativa?.
No entiendo bien eso de potenciómetros UART... quiere decir que desde la PC se envía un valor que especifica la posición deseada?, o el movimiento deseado a partir del actual?, o el valor de ejeX y ejeY que debe mantener el móvil (setpoint).

Releo... a ver si es algo así: querés pasarle por UART un par de coordenadas (X,Y) en una grilla de 32x32 (16 positivo y 16 negativo, quiero decir, x e y = -16 a +16) posiciones predefinidas en algún lugar.
¿Es así?
bueno ., con respecto a esto ., no lo tengo definido muy bien .,​
y creo que lo mas acertado seria poder usar las dos ., pero en funcion de una u otra ., ( para no complicarmos con las mezclas de funciones​
tengo muchisimos motores con bobinadosde distintos valores ., voltajes y del tipo unipolares o bipolares y todos con sus driver con comando por cuatro entradas​
asique si es por torque no hay problena ., (tanpoco le vamos a exigir a una hormiga ., que cargue una casa )​
el asunto es la velocidad ( tampoco se nesesita mucho) ., por lo menos la otra libreria que poseo ., y que combina el eje Z ., lo hace rapidicimoy solotrabaja con delays ., tal vez con timer sea mas estable ., pero no he probado​
si amigo esa es la idea ., puesto que combina las funciones negativas y positivas ( 16 pasos cada una) y sip no da una matriz de 32x32 como dijiste vos​
Ok, en el código veo las funciones para mover (incrementalmente/en forma relativa) los motores una cantidad fija de pasos en uno u otro eje.
Mi pregunta es: ¿como querés decirle al Arduino/Atmega qué movimientos tiene que realizar? (uart?, botones, presets) o quizás realiza un patrón de movimiento fijo y nada más?.
bueno yo tengo ya una libreria que trabaja por USART ., con su programa​
tengo la posibilidad de manejar hasta 256 potenciometros virtuales ., y que cada valor esta almacenado en un BUFFER
y ese valor puede ser reflejado o leido de manera muy simple., con eso puedo accionar las sentencias interna del programa ., o tener valores activos dentro del programa de acuerdo al valor del potenciometro​
aca te muestro comoseria para activar las funciones ., obiamente de un solo estado de eje (este caso X y positivo )​
los otros seian iguales solo cambia el numero de potenciometro (0) seguiria el (1) asignado ., por ejemplo a X negativo​
PHP:
 sei();										// Interrupts erlauben
 for (;;) {								// bucle sin fin
// ******* accionamiento funcion XPLUS (i) ********** //  
     if (PoteVirtual[0] < 7) {
      yplus16();
	 } else if(PoteVirtual[0] < 21) {
	  yplus15();
	 } else if (PoteVirtual[0] < 41) {
      yplus14();
	 } else if (PoteVirtual[0] < 61) {
      yplus13();
	 } else if (PoteVirtual[0] < 81) {
      yplus12();
	 } else if (PoteVirtual[0] < 101) {
      yplus11();
	 } else if (PoteVirtual[0] < 121) {
      yplus10();
	 } else if (PoteVirtual[0] < 141) {
      yplus9();
	 } else if (PoteVirtual[0] < 161) {
      yplus8();
	 } else if (PoteVirtual[0] < 181) {
      yplus7();
	 } else if (PoteVirtual[0] < 201) {
      yplus6();
	 } else if (PoteVirtual[0] < 211) {
      yplus5();
	 } else if (PoteVirtual[0] < 221) {
      yplus4();
     } else if (PoteVirtual[0] < 231) {
      yplus3();
	 } else if (PoteVirtual[0] < 241) {
      yplus2();
	 } else if (PoteVirtual[0] < 255) {
      yplus1();
  
   
	
     	
     
    

   }
bueno asi es mas o menos lo que quiero hacer o si les parece de otra forma
Curioso que no aceptara las funciones, eran traducciones bastante simples que debían ser tomadas por cualquier compilador (y en cualquier lenguaje) a cualquier MCU que se escribiera con acceso directo a registros.

Siempre que veo los códigos que publican para el AVR Studio veo que mucho lo manejan directamente a registros, igual estoy acostumbrado ya que usando los MSP430 lo hago de la misma manera, lo que siempre me parece incomodo es el hacer 1<<BIT_DEL_REGISTRO para modificar un bit, veo que tienen marcados el bit del registro como desplazamiento, en mi caso los header usan valores hexadecimales así que si es el BIT7 es 0x80 en lugar de 7, todo se reduce a simplemente escribir REGISTRO = BITn
bueno eso se debe al IDE de arduino ., por ejemplo los estados de un pin/port son tri-estado ., y cuando vos lo declaras en la compilacion OUTPUT ., estas llamado a una funcion interna que te dice​
PHP:
  DDRB |= (1<<PB0) | (1<<PB1) | (1<<PB2);	// Salida pin 	
  PORTB= 0;
y eso es porque la definicion de puertos ., las tiene definida asi el micro prosesador (hoja de datos) ., ( un atmega328p de arduino es el mismo atmega328p., que te venden suelto)​
aunque parezca sensillo no lo es ., y si el compilador te acepta las tres formas de escribir un registro sin ningun problema​
pero es dificilicimo de entender y leer que se quiso hacer mas si te pasas a otro micro ., que no es el cual se a escrito el programa​
si fuera al revez ., imaginate en mi micro tengo puerto A ., b ., C ., D y E​
y eso es mala costumbre ., porque no todos los registros de los uC .,se manejan igual​
., mas si es una IDE como AVRstudio ., que te da la posibilidad de programar mas de 30 uC diferents tanto en C como en ASM ( en la misma IDE)​
si se podria hacer asi ., sin problemas ., la sintaxix la podes acortar ., pero no entendes nada del codigo​
si queres saber que se esta haciendo (o hace si lo escribio otro)​
ese error es muy comun ., pero por unas cuantas letras ., simbolos y numeros que te ahorras ., perdes en el entendimiento del programa​
 
#20
esto es simple ., sobre un giro de 360° ., y se coloca un circulo asociado al eje (carton ., chapa ., plastico ., ETC)​
y se le hace una pequeña ranura ., con un interuptor opctico (de ranura tambien) se detecta esa ranura ., y manda el pin del micro a GND (sensor)​
y te puedo asegurar que no falla nunca ., aparet de ser rapidisimo


Exactamente (y), solo para que el micro tenga forma de saber si por algún motivo el motor se atascó.

bueno ., con respecto a esto ., no lo tengo definido muy bien .,​
y creo que lo mas acertado seria poder usar las dos ., pero en funcion de una u otra ., ( para no complicarmos con las mezclas de funciones​
tengo muchisimos motores con bobinadosde distintos valores ., voltajes y del tipo unipolares o bipolares y todos con sus driver con comando por cuatro entradas ...

Ah... entiendo hay que pensar en una buena estructura de código para no tener cosas repetidas y que sea entendible.
Deberías tener una estructura conteniendo la info necesaria de cada motor, y las funciones para hacer funcionar el motor deberían usar esa información para manejar las entradas/salidas de la forma que corresponda.

asique si es por torque no hay problena ., (tanpoco le vamos a exigir a una hormiga ., que cargue una casa )​
el asunto es la velocidad ( tampoco se nesesita mucho) ., por lo menos la otra libreria que poseo ., y que combina el eje Z ., lo hace rapidicimoy solotrabaja con delays ., tal vez con timer sea mas estable ., pero no he probado

Y cual es el problema con la velocidad?, así como esta trabaja muy lento?.
La velocidad la cambias con el delay de activación/desactivación de las salidas.
En tus rutinas estas utilizando _delay_us(2750); por ejemplo en la rutina xplus4.
Son 4 pasos con 8 delays -> 2750 us/delay * 8 delay / 4 pasos = 5500 us / paso = 5.5 ms/paso
Si tenes un motor de 400 pasos por revolución: 400 pasos / rev * 5.5 ms / paso * 1 s / 1000 ms = 2.2s /rev
1 rev/2.2s = 0.45 rev/s * 60 s/min = 27 rpm aprox
En fin, de esa forma aproximas la velocidad del motor de acuerdo al tiempo entre pasos, y claro, depende de los datos del motor (pasos por revolución).
Es decir, si con 2750 us tienes 27 rpm, con 2750/2 = 1375 us tendras 54 rpm aprox.

En cuanto a trabajar con timer, sí, podrías correr el código de secuencia de pasos (quizás usando una función similar a la que propuse :rolleyes:) en la rutina de interrupción del temporizador, y que el valor de comparación del comparador salga de la velocidad de rotación deseada del motor. Y con eso tu programa en el main solo tiene que setear cuando iniciar el movimiento (habilitando la interrupción y estableciendo la cuenta de pasos) y después el programa principal no se entera.
Pero quizás para hacer esto es difícil de hacer en este punto y para no complicarte seguí con los retardos, que no son para nada lo ideal pero bueno, no se muere nadie.

si amigo esa es la idea ., puesto que combina las funciones negativas y positivas ( 16 pasos cada una) y sip no da una matriz de 32x32 como dijiste vos

bueno yo tengo ya una libreria que trabaja por USART ., con su programa​
tengo la posibilidad de manejar hasta 256 potenciometros virtuales ., y que cada valor esta almacenado en un BUFFER
y ese valor puede ser reflejado o leido de manera muy simple., con eso puedo accionar las sentencias interna del programa ., o tener valores activos dentro del programa de acuerdo al valor del potenciometro​
aca te muestro comoseria para activar las funciones ., obiamente de un solo estado de eje (este caso X y positivo )​
los otros seian iguales solo cambia el numero de potenciometro (0) seguiria el (1) asignado ., por ejemplo a X negativo​
PHP:
 sei();                                        // Interrupts erlauben
 for (;;) {                                // bucle sin fin
// ******* accionamiento funcion XPLUS (i) ********** //  
     if (PoteVirtual[0] < 7) {
      yplus16();
     } else if(PoteVirtual[0] < 21) {
      yplus15();
     } else if (PoteVirtual[0] < 41) {
      yplus14();
     } else if (PoteVirtual[0] < 61) {
      yplus13();
     } else if (PoteVirtual[0] < 81) {
      yplus12();
     } else if (PoteVirtual[0] < 101) {
      yplus11();
     } else if (PoteVirtual[0] < 121) {
      yplus10();
     } else if (PoteVirtual[0] < 141) {
      yplus9();
     } else if (PoteVirtual[0] < 161) {
      yplus8();
     } else if (PoteVirtual[0] < 181) {
      yplus7();
     } else if (PoteVirtual[0] < 201) {
      yplus6();
     } else if (PoteVirtual[0] < 211) {
      yplus5();
     } else if (PoteVirtual[0] < 221) {
      yplus4();
     } else if (PoteVirtual[0] < 231) {
      yplus3();
     } else if (PoteVirtual[0] < 241) {
      yplus2();
     } else if (PoteVirtual[0] < 255) {
      yplus1();
   }
bueno asi es mas o menos lo que quiero hacer o si les parece de otra forma
Ajá... a ver... entonces a través de los potenciómetros UART se fija la posición del móvil en la cuadrilla XY.

Lo primero que se me ocurre (para nada lo más adecuado pero es un principio) es que el programa funcione más o menos así:

[Diagrama hecho online con http://www.planttext.com/planttext usando plantUML]
Código plantUML:
Código:
@startuml

title Diagrama posicionador UART

start

:Recibo paquete UART;
:Obtengo posición X/Y deseada;
:Comparo con posición X/Y actual;
if(diferencia con eje X) then (si) 
:moverEjeX(diferencia);
else (no)
endif
if(diferencia con eje Y) then (si) 
:moverEjeY(diferencia);
else (no)
endif

stop

@enduml
Después si querés que aumente la velocidad cuando más lejos esté la posición actual de la deseada, podrías hacer algo como:


Código:
@startuml

title Diagrama posicionador UART

start

:Recibo paquete UART;
:Obtengo posición X/Y deseada;
:Comparo con posición X/Y actual;
if(diferencia con eje X) then (si) 
    if(diferencia > 200 pasos) then (si)
        :velocidad = 100%;
    elseif (diferencia > 150 pasos) then (si)
        :velocidad = 75%;
    elseif (diferencia > 100 pasos) then (si)
        :velocidad = 50%;
    elseif (diferencia > 50 pasos) then (si)
        : velocidad = 25%;
    else
        :velocidad = 15%;
    endif
    :moverEjeX(diferencia, velocidad);
else (no)
endif
:idem eje Y;
stop

@enduml
Bueno, ya te dí bastante en que pensar, conclusión: velocidad depende del tiempo de retardo; ahora en este momento esta bien que pienses la estructura general del programa y decidas que parámetros de entrada y salida vas a manejar (tanto en el UART como en las funciones para mover los motores, etc).
 

Temas similares