forked from MAVProxyUser/YushuTechUnitreeGo1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
goShooty.ino
64 lines (59 loc) · 1.39 KB
/
goShooty.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
62
63
64
#include <map>
#include <BluetoothSerial.h>
BluetoothSerial SerialBT;
esp_spp_sec_t sec_mask=ESP_SPP_SEC_NONE;
esp_spp_role_t role=ESP_SPP_ROLE_SLAVE;
String readString;
int count = 0;
void setup() {
pinMode(13, OUTPUT);
Serial.begin(115200);
if(! SerialBT.begin("Unitree pew pew switch", true) ) {
Serial.println("========== serialBT failed!");
abort();
}
uint8_t addr[6] = {0x98, 0xda, 0x10, 0x01, 0x18, 0x4e};
Serial.println("connecting to 98da1001184e");
SerialBT.connect(addr, 1, sec_mask, role);
}
void loop() {
if(! SerialBT.isClosed() && SerialBT.connected())
{
if(SerialBT.available())
{
String content = "";
char character;
while(SerialBT.available())
{
character = SerialBT.read();
content.concat(character);
}
if (content != "") {
//Serial.println(content);
byte a = content[16];
//Serial.print(a, HEX);
//Serial.println();
if(a == 0x10)
{
count = count+1;
Serial.println("pew pew pew!");
if (count >= 5)
{
count = 0;
digitalWrite(13, HIGH);
delay(2000);
digitalWrite(13, LOW);
}
else
{
Serial.println(count);
}
}
//else
//{
// Serial.println("no pew pew");
//}
}
}
}
}