-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMIND_CONTROL.pde
57 lines (52 loc) · 1.57 KB
/
MIND_CONTROL.pde
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
import processing.serial.*;
int throttle = 0;
int yaw = 127;
int pitch = 127;
int roll = 127;
import cc.arduino.*;
Arduino arduino;
int Pin = 8;
void setup() {
arduino = new Arduino(this,"COM18", 57600);
arduino.pinMode(Pin, Arduino.OUTPUT);
size(150, 500);
//mindSet = new MindSet(this, "COM5");
smooth();
strokeWeight(5);
stroke(255);
strokeCap(SQUARE);
fill(255);
}
void draw()
{
background(0);
line( 0, height*0.60, width, height*.60);
line( width*.5, height, width*.5, height*map( float( attentionLevel ) / 100, 0, 1, 1, 0 ) );
throttle = int( map( attentionLevel, 40, 100, 30, 255 ) );
throttle = constrain( throttle, 0, 255);
pitch = constrain( pitch, 0, 255);
roll = constrain( roll, 0, 255);
yaw = constrain( yaw, 0, 255);
println( "attentionLevel: "+attentionLevel+" throttle: "+throttle+" yaw: "+yaw+" pitch: "+pitch+" roll: "+roll );
throttle=255;
arduino.analogWrite( Pin,throttle );
delay(1000);
throttle=0;
arduino.analogWrite( Pin,throttle );
delay(1000);
}
int signalStrenght = 0;
int attentionLevel = 0;
public void attentionEvent( int attentionLevel_val )
{
attentionLevel = attentionLevel_val;
}
public void poorSignalEvent( int signalNoise )
{
// MindSet is adjusting
if ( signalNoise == 200 ) {
println( "Mindset is not touching your skin!" );
}
signalStrenght = int( map( ( 200-signalNoise ), 200, 0, 100, 0 ) );
println( "Signal strength: " + signalStrenght + "%" );
}