Hello!
Hi
would you please write a sample code for counting steps of stepper motor?
Thanks
Counting steps is not more difficult than counting beans or tomatoes, it's just a matter of counting.
Now I have auto-indented your code, and the result is as follows:
Code C - [expand] |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
| void MyFunc(void) {
i=50;
while(PINB.1=0) {
for(j=0;j<200;j++) {
PORTC=0b00000011;
delay_ms(i);
PORTC=0b00000110;
delay_ms(i);
PORTC=0b00001100;
delay_ms(i);
PORTC=0b00001001;
delay_ms(i);
}
if(PINB.1=1) {
PORTC=0x00;
}
if((j>5)||(j<14)) {
PORTD.2=1;
}
else {
PORTD.3=1;
}
}
}
} |
Here are the following problems:
1. You have more closing brackets than opening brackets.
2. This line will not work: while(PINB.1=0)
3. This line will not work: if(PINB.1=1)
4. If you fix both lines above, do you think the (3) will ever happen?
As it is inside of the (2) loop, it will never happen.
5. You have a for loop with j going from 0 to 200 (not included), and
after this, you test whether j is between 5 and 14. Do you think this
will ever happen?
etc, etc...
Instead of asking people to write your code, try to write yours with coherent indents.
If you don't, nobody is going to understand your code, and I'm afraid you will never understand
it yourself.
Dora.