/* The pin numbers that the
* driver boards are connected
*/
uint8_t pins[8] = {1,2,3,4,5,6,7,8};
uint32_t tick[4];
void turnOn(uint8_t num,uint8_t dir){
tick[num]=millis(); //store time switched on
digitalWrite(pins[num*2],LOW); //ensure both outputs are low
digitalWrite(pins[num*2+1],LOW);
if(dir==1){
digitalWrite(pins[num*2],HIGH); //move CW
}else{
digitalWrite(pins[num*2+1],HIGH); //move CCW
}
}
void turnOff(){
for(uint8_t i=0;i<4;i++){
if(tick[i]>0){ //is this output on?
if((millis()-tick)>=75){ //has it been on for 75mS?
digitalWrite(pins[i*2],LOW); //turn it off
digitalWrite(pins[i*2+1],LOW);
tick[i]=0; //clear time
}
}
}
}