-
Notifications
You must be signed in to change notification settings - Fork 0
/
serialTest.ino
61 lines (57 loc) · 1.52 KB
/
serialTest.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
byte incomingBytes[3] = {0, 0, 0};
int working_Part = 0;
int target_Speed = 0;
int target_Position = 0;
void setup()
{
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop()
{
// put your main code here, to run repeatedly:
if (Serial.available() > 0)
{
//Attempt to read in our command
read_Command();
switch(working_Part)
{
case 0:
Serial.print("Move jaw to ");
Serial.print(target_Position, DEC);
Serial.print(" at speed: ");
Serial.println(target_Speed, DEC);
break;
case 1:
Serial.print("Move lip to ");
Serial.print(target_Position, DEC);
Serial.print(" at speed: ");
Serial.println(target_Speed, DEC);
break;
case 2:
Serial.print("Move eyes to ");
Serial.print(target_Position, DEC);
Serial.print(" at speed: ");
Serial.println(target_Speed, DEC);
break;
case 3:
Serial.print("Move eyebrows to ");
Serial.print(target_Position, DEC);
Serial.print(" at speed: ");
Serial.println(target_Speed, DEC);
break;
default:
Serial.println("Unrecognized command");
break;
}
}
}
//Functions to catch and process our incoming bytes for our move commands
//May contain a lot of redundency but are mostly here to increase readability
void read_Command()
{
Serial.readBytes(incomingBytes, 3);
working_Part = incomingBytes[0];
target_Speed = incomingBytes[1];
target_Position = incomingBytes[2];
}