-
Notifications
You must be signed in to change notification settings - Fork 0
/
bb8v1_2.ino
61 lines (57 loc) · 1.41 KB
/
bb8v1_2.ino
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
#include <SoftwareSerial.h>
SoftwareSerial ble_device(2,3); //2 je TX a 3 RX
char a;
void setup() {
pinMode(8,OUTPUT); //prvi motor napred
pinMode(9,OUTPUT); //prvi motor nazad
pinMode(10,OUTPUT); //drugi motor napred
pinMode(11,OUTPUT); //drugi motor nazad
ble_device.begin(9600);
}
void loop() {
if (ble_device.available()>0)
{
a=ble_device.read();
ble_device.println(a);
}
if (a=='F') //forward
{
digitalWrite(8,HIGH);
digitalWrite(9,LOW);
digitalWrite(10,LOW);
digitalWrite(11,HIGH);
//f forward
//B back
//L left
//forwar right I
}
else if (a=='B') //back
{
digitalWrite(8,LOW);
digitalWrite(9,HIGH);
digitalWrite(10,HIGH);
digitalWrite(11,LOW);
}
else if (a=='R') //forward right
{
digitalWrite(8,HIGH);
digitalWrite(9,LOW);
digitalWrite(10,LOW);
digitalWrite(11,LOW);
}
else if (a=='L') //forward left
{
digitalWrite(8,LOW);
digitalWrite(9,LOW);
digitalWrite(10,LOW);
digitalWrite(11,HIGH);
}
else if (a=='S')
{
digitalWrite(8,LOW);
digitalWrite(9,LOW);
digitalWrite(10,LOW);
digitalWrite(11,LOW);
}
delay(100);
}