forked from alexsonablaza/Team11
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathServoMEGA.ino
73 lines (62 loc) · 1.59 KB
/
ServoMEGA.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
#include <Servo.h>
//#include <Brain.h>
int ServoP1 = 7; //Servo Pin
Servo regServ1; //Servo Object
String inDat = " ";
void setup()
{
// put your setup code here, to run once:
regServ1.attach(ServoP1); //Attach
regServ1.write(0);
Serial.begin (9600); //Activate Serial Comms.
ServoWriter(®Serv1);
}
byte ReadOneByte(){
int ByteRead;
while(!Serial.available());
ByteRead = Serial.read();
Serial.print((char)ByteRead);
Byte = ByteRead.toInt();
return ByteRead;
}
byte attention = 0;
int recv_byte = 0; //
String inString = "";
void loop()
{
ServoWriter(®Serv1);
/*brainValue = serial.readCSV(); //character string with latest brain values
lgamma = serial.readLowGamma(); //reads low gamma waves
hgamma = serial.readHighGamma(); //reads high gamma waves
lbeta = serial.readLowBeta(); //reads low beta waves
hbeta = serial.readHighBeta(); //reads high beta waves
*/
}
int ServoWriter(Servo *regServ1)
{
// put your main code here, to run repeatedly:
while (Serial.available()== 0)
{
//Check Serial for Data.
}
/*inDat = Serial.readString();
Serial.print("Number Entered: ");
Serial.println(inDat);
recv_byte =inDat.toInt();
intHgamma = hgamma.toInt(); //converts string to integer
intLgamma = lgamma.toInt();
intLbeta = lbeta.toInt();
intHbeta = hbeta.toInt();
*/
Serial.print(attention, DEC);
pos = 180 //position
if (isDigit(attention) && (attention >= 0) || (attention <= 180))
{
regServ1-> write(pos);
delayMicroseconds(100);
}
else
{
Serial.println ("Enter a Valid Number");
}
}