Betulpeker (talk | contribs) No edit summary |
Betulpeker (talk | contribs) No edit summary |
||
Line 55: | Line 55: | ||
<source style="border:none; height:650px; overflow:scroll;" lang="c" line start="55" highlight="4"> | <source style="border:none; height:650px; overflow:scroll;" lang="c" line start="55" highlight="4"> | ||
import processing.serial.*; | import processing.serial.*; | ||
Serial myPort; | Serial myPort; | ||
String incomingData = null; | String incomingData = null; | ||
float rawSensorData = 0; | float rawSensorData = 0; | ||
boolean buttonPressed; | boolean buttonPressed; | ||
boolean pastButtonData = false, currentButtonData = false; | boolean pastButtonData = false, currentButtonData = false; | ||
Line 65: | Line 64: | ||
//tıme and date | //tıme and date | ||
int h,m,s; | int h,m,s; | ||
String dataName = "positions2601"; | String dataName = "positions2601"; | ||
String folderName = "folder01"; | String folderName = "folder01"; | ||
int imgCounter = 0; | int imgCounter = 0; | ||
void setup() { | void setup() { | ||
size(500, 500); | size(500, 500); | ||
String portName = Serial.list()[2]; | String portName = Serial.list()[2]; | ||
myPort = new Serial(this, portName, 9600); | myPort = new Serial(this, portName, 9600); | ||
myPort.bufferUntil('\n'); | myPort.bufferUntil('\n'); | ||
background (255); | background (255); | ||
output = createWriter("/Users/machd/Desktop/speculative atmospheres II : final/"+folderName+"/"+dataName+".txt"); | output = createWriter("/Users/machd/Desktop/speculative atmospheres II : final/"+folderName+"/"+dataName+".txt"); | ||
} | } | ||
Line 95: | Line 94: | ||
// it allows you to use the incoming data in the draw() function, you do not need to change this. | // it allows you to use the incoming data in the draw() function, you do not need to change this. | ||
void serialEvent(Serial myPort) { | void serialEvent(Serial myPort) { | ||
incomingData = myPort.readString(); | incomingData = myPort.readString(); | ||
r = float(trim(incomingData.split(" ")[0])); | r = float(trim(incomingData.split(" ")[0])); | ||
g = float(trim(incomingData.split(" ")[1])); | g = float(trim(incomingData.split(" ")[1])); | ||
Line 112: | Line 111: | ||
} | } | ||
//rawSensorData = float(trim(incomingData)); | //rawSensorData = float(trim(incomingData)); | ||
//println (rawSensorData); | //println (rawSensorData); | ||
println (incomingData); | println (incomingData); | ||
myPort.clear(); | myPort.clear(); | ||
pastButtonData = currentButtonData; | pastButtonData = currentButtonData; | ||
} | } | ||
void getTime(){ | void getTime(){ | ||
h=hour(); | h=hour(); | ||
m=minute(); | m=minute(); | ||
Line 126: | Line 125: | ||
//println(h,m,s); | //println(h,m,s); | ||
String time = str(h)+":"+str(m)+":"+str(s)+ "-" + str(buttonPressed); | String time = str(h)+":"+str(m)+":"+str(s)+ "-" + str(buttonPressed); | ||
} | } | ||