Go Down

Topic: Reading current step position of LN298 (Read 1 time) previous topic - next topic

sbright33

My complete code is attached below as a zip. 
I want to modify it like this to move the motor to the current step every 2ms:
Can you see any problem with my code?

Code: [Select]

delay(2000);
currentStep=digitalRead(pin2);  //read value
pinMode(pin2,OUTPUT);
digitalWrite(pin2,currentStep);  //output current step on pin 2
currentStep=digitalRead(pin3);
pinMode(pin3,OUTPUT);
digitalWrite(pin3,currentStep);  //output current step on pin 3
currentStep=digitalRead(pin4);
pinMode(pin4,OUTPUT);
digitalWrite(pin4,currentStep);  //output current step on pin 4
currentStep=digitalRead(pin5);
pinMode(pin5,OUTPUT);
digitalWrite(pin5,currentStep);  //output current step on pin 5

jwatte


My complete code is attached below as a zip. 
I want to modify it like this to move the motor to the current step every 2ms:
Can you see any problem with my code?


Your code assumes that hardware pins can work as both output and input, switching on the fly. Sadly, that's not actually the case. The driving pin is an output, because it's an input on the LN298.
Because the LN298 doesn't provide any signal you can read, what does "step to current current step" actually mean in your question?

sbright33

I believe you CAN switch them on the fly, if the external hardware is configured as such.  I'm sorry to ask the question I did.  I now realize it's hard to tell the difference between a question like this in the beginning of the month, and a question by a new user.  Please forgive me for not thinking about it more before I asked.  Don't give the error I made?

Go Up