Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Renamed LampDemo to LEDDemo
  • Loading branch information
amd11037 committed Apr 16, 2015
1 parent 16b32f5 commit 3ec72a4
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 30 deletions.
8 changes: 2 additions & 6 deletions .classpath
@@ -1,14 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path=""/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
<accessrules>
<accessrule kind="accessible" pattern="gnu/io/**"/>
</accessrules>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/Java SE 8 [1.8.0_25]"/>
<classpathentry kind="lib" path="/Library/Java/Extensions/RXTXcomm.jar"/>
<classpathentry kind="lib" path="/Users/x/Downloads/org.json-20120521.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/Emotiv-JSON-API"/>
<classpathentry kind="lib" path="/Users/x/Downloads/Example_C++_Mac/Java/lib/jna.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/Emotiv-JSON-API"/>
<classpathentry kind="output" path=""/>
</classpath>
2 changes: 2 additions & 0 deletions .gitignore
@@ -1 +1,3 @@
/LampDemo.class
/Test.class
/LEDDemo.class
2 changes: 1 addition & 1 deletion .project
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>ArduinoOSX</name>
<name>EmoJArduino</name>
<comment></comment>
<projects>
</projects>
Expand Down
7 changes: 4 additions & 3 deletions .settings/org.eclipse.jdt.core.prefs
@@ -1,11 +1,12 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6
org.eclipse.jdt.core.compiler.source=1.8
39 changes: 19 additions & 20 deletions LampDemo.java → LEDDemo.java
Expand Up @@ -7,16 +7,16 @@ import java.net.UnknownHostException;
import org.json.*;
import arduino.Arduino;

public class LampDemo {
private static boolean LAMP_ON = false;
public class LEDDemo {
private static boolean LED_ON = false;
public static void main(String[] args) throws UnknownHostException, IOException, JSONException {
double threshold = 0.5;
Arduino ard = new Arduino("/dev/cu.usbserial-AD01VFL0");
Arduino ard = new Arduino("/dev/cu.usbserial-AD01VFL0"); //change this
//connect the Arduino
ard.connect();
String params;
String JSONResponse;
BufferedReader inFromUser = new BufferedReader( new InputStreamReader(System.in));
BufferedReader inFromUser = new BufferedReader(new InputStreamReader(System.in));

//run API_Main for the EPOC server socket
try {
Expand All @@ -27,8 +27,8 @@ public class LampDemo {
Socket clientSocket = new Socket("localhost", 2222);
DataOutputStream outToServer = new DataOutputStream(clientSocket.getOutputStream());

//get user param and use that to turn on the lamp and send to server
System.out.println("Enter 2 EEG events to control lamp (separated by commas): ");
//get user param and use that to turn on the LED and send to server
System.out.println("Enter 2 EEG events to control LED (separated by commas): ");
BufferedReader inFromServer = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
params = inFromUser.readLine();
outToServer.writeBytes(params + '\n');
Expand All @@ -48,12 +48,12 @@ public class LampDemo {
for (int i = 0; i < array.length(); i++) {
double param_val = array.getJSONObject(i).getDouble(token);
if (param_val > threshold && token == tokens[0]) {
//turn on lamp
lampSwitch(ard, LAMP_ON);
//turn on LED
LEDSwitch(ard);
}
else if (param_val > threshold && token == tokens[1]) {
//turn off lamp
lampSwitch(ard, LAMP_ON);
//turn off LED
LEDSwitch(ard);
}
}
}
Expand All @@ -63,12 +63,12 @@ public class LampDemo {
if (cog_action.equals(token)) {
double param_val = obj.getJSONObject("EmoStateData").getDouble("Cognitiv");
if (param_val > threshold && token == tokens[0]) {
//turn on lamp
lampSwitch(ard, LAMP_ON);
//turn on LED
LEDSwitch(ard);
}
else if (param_val > threshold && token == tokens[1]) {
//turn off lamp
lampSwitch(ard, LAMP_ON);
//turn off LED
LEDSwitch(ard);
}
}
}
Expand All @@ -91,16 +91,15 @@ public class LampDemo {
}
}

public static void lampSwitch(Arduino ard, boolean lampON) {
if (lampON) {
System.out.println("Shutting off lamp...");
public static void LEDSwitch(Arduino ard) {
if (LED_ON) {
System.out.println("Shutting off LED...");
ard.digitalWrite(13, false);
LAMP_ON = !LAMP_ON;
}
else {
System.out.println("Turning on lamp...");
System.out.println("Turning on LED...");
ard.digitalWrite(13, true);
LAMP_ON = !LAMP_ON;
}
LED_ON = !LED_ON;
}
}
Binary file modified Test.class
Binary file not shown.

0 comments on commit 3ec72a4

Please sign in to comment.