-
Notifications
You must be signed in to change notification settings - Fork 0
/
Transmitter.ino
83 lines (64 loc) · 1.74 KB
/
Transmitter.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
//Define pins
int thumb = 12;
int index = 11;
int middle = 10;
int ring = 9;
int pinky = 8;
char arrThumb[4];
char arrIndex[4];
char arrMiddle[4];
char arrRing[4];
char arrPinky[4];
void setup()
{
//Create Serial Object (9600 Baud)
Serial.begin(9600);
}
void loop()
{
int posThumb = map(analogRead(thumb), 520, 350, 0, 9);
posThumb = constrain(posThumb, 0, 9);
// Creating the character array for the thumb
arrThumb[0] = 'T';
arrThumb[1] = posThumb +'0';
arrThumb[2] = '.';
// Serial.println(thumb);
//delay(500);
int posIndex = map(analogRead(index), 550, 250, 0, 9);
posIndex = constrain(posIndex, 0, 9);
// Creating the character array for the index finger
arrIndex[0] = 'I';
arrIndex[1] = posIndex +'0';
arrIndex[2] = '.';
// Serial.println(index);
// delay(500);
int posMiddle = map(analogRead(middle), 560, 270, 0, 9);
posMiddle = constrain(posMiddle, 0, 9);
// Creating the character array for the middle finger
arrMiddle[0] = 'M';
arrMiddle[1] = posMiddle +'0';
arrMiddle[2] = '.';
// Serial.println(middle);
// delay(500);
int posRing = map(analogRead(ring), 640, 270, 0, 9);
posRing = constrain(posRing, 0, 9);
// Creating the character array for the ring finger
arrRing[0] = 'R';
arrRing[1] = posRing +'0';
arrRing[2] = '.';
//Serial.println(ring);
//delay(500);
int posPinky = map(analogRead(pinky), 570, 280, 0, 9);
posPinky = constrain(posPinky, 0, 9);
// Creating the character array for the pinky
arrPinky[0] = 'P';
arrPinky[1] = posPinky +'0';
arrPinky[2] = '.';
//Serial.println(pinky);
delay(200);
Serial.println(arrThumb);
Serial.println(arrIndex);
Serial.println(arrMiddle);
Serial.println(arrRing);
Serial.println(arrPinky);
}