1#include <Servo.h>
2Servo myservo;
3int pos = 0;
4
5
6
7void setup()
8
9{
10
11Serial.begin(9600);
12while (!Serial);
13Serial.println("-------------------------");
14Serial.println("ARos is loading....");
15delay(1000);
16Serial.println("ARos loaded succesfully");
17Serial.println("-------------------------");
18myservo.attach(9);
19Serial.println("calibrating servo...");
20for(pos = 0; pos <= 180; pos += 1)
21myservo.write(0);
22delay(1000);
23myservo.write(180);
24delay(1000);
25myservo.write(90);
26delay(1000);
27Serial.println("servo calibrated");
28Serial.println("-------------------------");
29Serial.println("Comand input online, write command to perform action");
30Serial.println("-------------------------");
31
32}
33
34void loop() {
35
36for(pos = 0; pos <= 180; pos += 1)
37if (Serial.available())
38
39
40{
41 int state = Serial.parseInt();
42
43if (state < 10)
44
45{
46Serial.print(">");
47Serial.println(state);
48Serial.println("cannost execute command, too low number");
49
50}
51
52if (state >= 10 && state < 170)
53{
54 Serial.print(">");
55 Serial.println(state);
56 Serial.print("turning servo to ");
57 Serial.print(state);
58 Serial.println(" degrees");
59 myservo.write(state);
60
61}
62
63}
64
65}
66
67
68
69