How to fix my Serial.print for HEXAPOD ROBOT

#include <Servo.h>

Servo servoleg1A;
Servo servoleg2A;
Servo servoleg3A;
int posA = 0;
// SERVO LEG A \\

void setup()
{
servoleg1A.attach(2);
servoleg2A.attach(3);
servoleg3A.attach(4);
Serial.begin(9600);
Serial.println ("HEXAPOD");

servoleg1A.write(30);
}

void loop()
{
for ( posA= 0; posA <= 90; posA += 1)
{
Serial.println ("\t");
servoleg1A.write(posA);
delay(60);

if (posA <= 90)
{
Serial.println (posA);
}
else if ( (90 < posA) <= 0)
{
Serial.println(posA);
}
}

for ( posA= 120; posA >= 0; posA -= 1)
{
Serial.println (posA);
Serial.print ("\t");
Serial.println (" >> FORWARD / 0.6s ");
servoleg1A.write(posA);
delay(60);
}
while (1);
}

** Here the problem, that was my program, i want to measure the servo movement by using Serial.println,
but the result on Serial monitor is like this **

HEXAPOD

0

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

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90
120

FORWARD / 0.6s
119
FORWARD / 0.6s
118
FORWARD / 0.6s
117
FORWARD / 0.6s
116
FORWARD / 0.6s
115
FORWARD / 0.6s
114
FORWARD / 0.6s
113
FORWARD / 0.6s
112
FORWARD / 0.6s
111
FORWARD / 0.6s
110
FORWARD / 0.6s
109
FORWARD / 0.6s
108
FORWARD / 0.6s
107
FORWARD / 0.6s
106
FORWARD / 0.6s
105
FORWARD / 0.6s
104
FORWARD / 0.6s
103
FORWARD / 0.6s
102
FORWARD / 0.6s
101
FORWARD / 0.6s
100
FORWARD / 0.6s
99
FORWARD / 0.6s
98
FORWARD / 0.6s
97
FORWARD / 0.6s
96
FORWARD / 0.6s
95
FORWARD / 0.6s
94
FORWARD / 0.6s
93
FORWARD / 0.6s
92
FORWARD / 0.6s
91
FORWARD / 0.6s
90
FORWARD / 0.6s
89
FORWARD / 0.6s
88
FORWARD / 0.6s
87
FORWARD / 0.6s
86
FORWARD / 0.6s
85
FORWARD / 0.6s
84
FORWARD / 0.6s
83
FORWARD / 0.6s
82
FORWARD / 0.6s
81
FORWARD / 0.6s
80
FORWARD / 0.6s
79
FORWARD / 0.6s
78
FORWARD / 0.6s
77
FORWARD / 0.6s
76
FORWARD / 0.6s
75
FORWARD / 0.6s
74
FORWARD / 0.6s
73
FORWARD / 0.6s
72
FORWARD / 0.6s
71
FORWARD / 0.6s
70
FORWARD / 0.6s
69
FORWARD / 0.6s
68
FORWARD / 0.6s
67
FORWARD / 0.6s
66
FORWARD / 0.6s
65
FORWARD / 0.6s
64
FORWARD / 0.6s
63
FORWARD / 0.6s
62
FORWARD / 0.6s
61
FORWARD / 0.6s
60
FORWARD / 0.6s
59
FORWARD / 0.6s
58
FORWARD / 0.6s
57
FORWARD / 0.6s
56
FORWARD / 0.6s
55
FORWARD / 0.6s
54
FORWARD / 0.6s
53
FORWARD / 0.6s
52
FORWARD / 0.6s
51
FORWARD / 0.6s
50
FORWARD / 0.6s
49
FORWARD / 0.6s
48
FORWARD / 0.6s
47
FORWARD / 0.6s
46
FORWARD / 0.6s
45
FORWARD / 0.6s
44
FORWARD / 0.6s
43
FORWARD / 0.6s
42
FORWARD / 0.6s
41
FORWARD / 0.6s
40
FORWARD / 0.6s
39
FORWARD / 0.6s
38
FORWARD / 0.6s
37
FORWARD / 0.6s
36
FORWARD / 0.6s
35
FORWARD / 0.6s
34
FORWARD / 0.6s
33
FORWARD / 0.6s
32
FORWARD / 0.6s
31
FORWARD / 0.6s
30
FORWARD / 0.6s
29
FORWARD / 0.6s
28
FORWARD / 0.6s
27
FORWARD / 0.6s
26
FORWARD / 0.6s
25
FORWARD / 0.6s
24
FORWARD / 0.6s
23
FORWARD / 0.6s
22
FORWARD / 0.6s
21
FORWARD / 0.6s
20
FORWARD / 0.6s
19
FORWARD / 0.6s
18
FORWARD / 0.6s
17
FORWARD / 0.6s
16
FORWARD / 0.6s
15
FORWARD / 0.6s
14
FORWARD / 0.6s
13
FORWARD / 0.6s
12
FORWARD / 0.6s
11
FORWARD / 0.6s
10
FORWARD / 0.6s
9
FORWARD / 0.6s
8
FORWARD / 0.6s
7
FORWARD / 0.6s
6
FORWARD / 0.6s
5
FORWARD / 0.6s
4
FORWARD / 0.6s
3
FORWARD / 0.6s
2
FORWARD / 0.6s
1
FORWARD / 0.6s
0
FORWARD / 0.6s

**I just want my Serial monitor can make view for every step degree
like this

When servo move from 0 to 90 it will count 1

then

when servo move from 90 it will count 2

and etc ....**

can anyone help me ?:frowning: sory for bad english.

 else if ( (90 < posA) <= 0)

That is not correct syntax. Not sure what you wanted it to do, so not sure how to correct. But this is definitely wrong.

i just want when the servo move from 0 to 90 degree
on Serial monitor will shown 1
And then back from 90 to 0 degree
on Serial monitor will shown 2
and thats all i needed till what ever it will count .......

that was my program actually i just try by googling

But you're printing the position you told the servo to move to, not any count of the number of moves. I don't understand.

hmm its okay sir, soryy if you cant understand what i mean..

can you tell me what is that means ?

if (posA <= 90)
{
Serial.println (posA);
}
else if ( (90 < posA) <= 0)
{
Serial.println(posA);
}

for Serial monitor actually

It means if the posA variable is less than or equal to 90 then print posA to Serial.

ELSE if the (posA variable is less than 90) is false then print posA to Serial.

The second part is complete rubbish and you'll have to explain what you thought it did before I can tell you how to do it right. I can't even tell what you meant with that line.

Agree, you can replace all that with serialprint ( posA);

It would help if you put comments in your code to explain what parts of it are supposed to do , that will help you spot issues, as will the odd “ debugging “ print statement to see what variable values are , even :

print (“im in this bit “);

Often helps !

I often put

//*****end of this bit ******

Between sections of code or procedures to improve readability and help Divide code up .
Really people responding here are doing that in their heads !

@Delta_G

okay i will try to explain what i means sir.

when i input data for servo like this
for ( posA= 0; posA <= 90; posA += 1)
{
Serial.println ("\t");
servoleg1A.write(posA);
delay(60);
}

it will shown on Serial.monitor
0

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

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

*what i want is when the servo move from 0 to 90, on serial mintor will shown 1.. so next 0 to 90 will shown 2, and more...
not 0 - 90 like that.

OK. But you understand that the position is going from 0 to 90 each time. Right? So why are you printing the position if that's not what you want to see? Create another variable and only add one each time the entire for loop completes and print that instead.

@Delta_G

yes sir.. Because i just try to create some Serial.print on it, then the variable that appears does not match what i want.

I dont know how to create that variable and only add one each time the entire for loop completes and print that instead like you said.

can you give me example for the code?

Please, midify your posts and use tag codes to made than chirter and better written

@Silente

okay i am sorry.. i just new here