1#include <Servo.h>
2Servo myservo;
3
4int val;
5int LED = 13;
6int IN4 = 4;
7int IN3 = 5;
8int IN2 = 7;
9int IN1 = 6;
10int k = 0;
11void setup()
12{
13Serial.begin(9600);
14pinMode(LED, OUTPUT);
15 pinMode (IN4, OUTPUT);
16 pinMode (IN3, OUTPUT);
17 pinMode (IN2, OUTPUT);
18 pinMode (IN1, OUTPUT);
19 myservo.attach(10);
20}
21
22void loop()
23{
24if (Serial.available())
25 {
26 val = Serial.read();
27
28 if (k == 0)
29 {
30 myservo.write(90);
31 k++;
32 }
33
34 if (val == 'X')
35 {
36 myservo.write(90);
37 }
38 if (val == 'x')
39 {
40 myservo.write(90);
41 }
42 if (val == 'F')
43 {
44 digitalWrite (IN4, HIGH);
45 digitalWrite (IN3, LOW);
46 digitalWrite (IN2, HIGH);
47 digitalWrite (IN1, LOW);
48 }
49
50 if ( val == 'S')
51 {
52 digitalWrite (IN3, LOW);
53 digitalWrite (IN4, LOW);
54 digitalWrite (IN2, LOW);
55 digitalWrite (IN1, LOW);
56 }
57
58 if ( val == 'B')
59 {
60 digitalWrite (IN4, LOW);
61 digitalWrite (IN3, HIGH);
62 digitalWrite (IN2, LOW);
63 digitalWrite (IN1, HIGH);
64 }
65
66 if ( val == 'L')
67 {
68 myservo.write(50);
69
70 }
71
72 if ( val == 'R')
73 {
74 myservo.write(130);
75
76 }
77
78
79
80
81 if (val == 'G')
82 {
83 digitalWrite (IN4, HIGH);
84 digitalWrite (IN3, LOW);
85 digitalWrite (IN2, HIGH);
86 digitalWrite (IN1, LOW);
87 myservo.write(50);
88 delay(1000);
89 myservo.write(90);
90 }
91
92
93 if ( val == 'I')
94 {
95 digitalWrite (IN4, HIGH);
96 digitalWrite (IN3,LOW);
97 digitalWrite (IN2, HIGH);
98 digitalWrite (IN1, LOW);
99 myservo.write(130);
100 delay(1000);
101 myservo.write(90);
102 }
103
104 if ( val == 'H')
105 {
106 digitalWrite (IN4, LOW);
107 digitalWrite (IN3, HIGH);
108 digitalWrite (IN1, HIGH);
109 digitalWrite (IN2, LOW);
110 myservo.write(130);
111 delay(1000);
112 myservo.write(90);
113 }
114
115 if ( val == 'J')
116 {
117 digitalWrite (IN4, LOW);
118 digitalWrite (IN3, HIGH);
119 digitalWrite (IN1, HIGH);
120 digitalWrite (IN2, LOW);
121 myservo.write(50);
122 delay(1000);
123 myservo.write(90);
124 }
125 }
126}
127
128