import processing.serial.*;
import java.awt.Robot;
import java.awt.event.KeyEvent;
import java.io.IOException;
Serial port;
String val="";
int index=0;
int index2=0;
String X="";
String Y="";
int iX=0;
int iY=0;
Robot robot;
void setup()
{
try
{
robot = new Robot();
}
catch (Exception e) {
e.printStackTrace();
exit();
}
delay(2000);
port = new Serial(this, "COM9", 9600);
}
void draw()
{
while(port.available()>0){
val=port.readStringUntil('.');
if(val!=null){
index = val.indexOf(","); if (index<0){index=0; delay(10);}
X= val.substring(0, index);
index2 = val.indexOf("."); if (index2<0){index2=0; delay(10);}
Y=val.substring(index+1,index2);
iX=int(X);
iY=int(Y);
print(iX);
print(" ");
println(iY);
if (iY>-60){
robot.keyPress(KeyEvent.VK_S);
delay(15);
}
if (iY<-60){
robot.keyRelease(KeyEvent.VK_S);
delay(15);
}
delay(20);
}
}
}
import processing.serial.*;
Serial port,port2;
String val="";
int index=0;
int index2=0;
String X="";
String Y="";
int iX=0;
int iY=0;
void setup()
{
port = new Serial(this, "COM9", 9600);
delay(1000);
port2 = new Serial(this,"COM7", 9600);
}
void draw()
{
while(port.available()>0){
val=port.readStringUntil('.');
if(val!=null){
index = val.indexOf(","); if (index<0){index=0; delay(10);}
X= val.substring(0, index);
index2 = val.indexOf("."); if (index2<0){index2=0; delay(10);}
Y=val.substring(index+1,index2);
iX=int(X);
iY=int(Y);
print(iX);
print(" ");
println(iY);
delay(20);
}
}
}
SpaceApps is a NASA incubator innovation program.