-
Notifications
You must be signed in to change notification settings - Fork 0
/
ServoBLE.ino
111 lines (102 loc) · 2.38 KB
/
ServoBLE.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
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/**
* Vishal Chandra
* 5/29/19
*
* Controlling 5 servos remotely using BLE
* Notes: Hold boot button until "Connecting....." appears,
* then let go and program should write to board
*/
#define BLYNK_PRINT Serial
#define BLYNK_USE_DIRECT_CONNECT
#include "src/Hand/Hand.h"
#include "src/Gesture/Gesture.h"
#include <BlynkSimpleEsp32_BLE.h>
#include <BLEDevice.h>
#include <BLEServer.h>
// App auth token. Establishes connection to app.
char auth[] = "7e305e4259c24f6795f3a723d8657e5c"; //personal
//char auth[] = "ee9e940474f246bc95265ab9c8b0975e"; //pennucci
#define pinkypin 32
#define thumbpin 33
#define ringpin 25
#define indexpin 26
#define middlepin 27
Hand hand;
//gestures
Gesture Gopen = Gesture(0, 0, 0, 0, 0); //on pin V5
Gesture Gclose = Gesture(180, 180, 180, 180, 180); //on pin V6
Gesture Gtrump = Gesture(0, 0, 0, 180, 100); //on pin V7
Gesture Gflip = Gesture(180, 180, 0, 180, 180); //on pin V8
//pinky (block left side)
BLYNK_WRITE(V0){
//get and send slider info
int angle = param.asInt();
hand.pinky.write(angle);
}
//thumb
BLYNK_WRITE(V1){
//get and send slider info
int angle = param.asInt();
hand.thumb.write(angle);
}
//ring (block left side)
BLYNK_WRITE(V2){
//get and send slider info
int angle = param.asInt();
hand.ring.write(angle);
}
//index
BLYNK_WRITE(V3){
//get and send slider info
int angle = param.asInt();
hand.findex.write(angle);
}
//middle
BLYNK_WRITE(V4){
//get and send slider info
int angle = param.asInt();
hand.middle.write(angle);
}
//open button tapped
BLYNK_WRITE(V5) {
int pushed = param.asInt();
if(pushed) {
hand.performGesture(Gopen);
Serial.write("open requested\n");
}
}
//close button tapped
BLYNK_WRITE(V6) {
int pushed = param.asInt();
if(pushed) {
hand.performGesture(Gclose);
Serial.write("close requested\n");
}
}
//trump button tapped
BLYNK_WRITE(V7) {
int pushed = param.asInt();
if(pushed) {
hand.performGesture(Gtrump);
Serial.write("trump requested\n");
}
}
//flip off button tapped
BLYNK_WRITE(V8) {
int pushed = param.asInt();
if(pushed) {
hand.performGesture(Gflip);
Serial.write("flip off requested\n");
}
}
void setup(){
hand = Hand(pinkypin, ringpin, middlepin, indexpin, thumbpin);
//misc
Serial.begin(9600);
Serial.println("Waiting for connections...");
Blynk.setDeviceName("Vishal & Sophia");
Blynk.begin(auth);
}
void loop(){
Blynk.run();
}