171
edits
Diannamertz (talk | contribs) mNo edit summary |
Diannamertz (talk | contribs) mNo edit summary |
||
Line 15: | Line 15: | ||
===Code=== | ===Code=== | ||
====Arduino==== | |||
<source lang="java"> | <source lang="java"> | ||
int IRpin = 1; | int IRpin = 1; | ||
Line 28: | Line 28: | ||
float distance = 12.21*pow(volts, -1.15); | float distance = 12.21*pow(volts, -1.15); | ||
Serial.println(distance); | Serial.println(distance); | ||
} | |||
</source> | |||
====Processing==== | |||
<source lang="java"> | |||
Serial myPort; | |||
Table dataTable; | |||
import processing.serial.*; | |||
int incomingVal; | |||
int r; | |||
int b; | |||
int q; | |||
int o; | |||
void setup(){ | |||
size(255,255); | |||
dataTable = new Table("data.tsv"); | |||
myPort = new Serial(this,"/dev/tty.usbmodem411",9600); | |||
} | |||
void draw(){ | |||
background(0); | |||
while(myPort.available() > 0){ | |||
incomingVal = myPort.read(); | |||
} | |||
fill(incomingVal); | |||
rect(0,height-incomingVal,width,height); | |||
PrintWriter output = createWriter("data/data.tsv"); | |||
output.println("Pasta:" +incomingVal+ " Rice:" +r+ " Bulgar:" +b+ " Quinoa:" +q+ " Oats:" +o ); | |||
output.flush(); | |||
output.close(); | |||
} | } | ||
</source> | </source> | ||
Line 33: | Line 65: | ||
===References=== | ===References=== | ||
[http://www.sparkfun.com/datasheets/Sensors/Infrared/GP2D120XJ00F_SS.pdf Reference for Sharp GP2D120XJ00F Analog Distance Sensor 4-30cm] <br> | [http://www.sparkfun.com/datasheets/Sensors/Infrared/GP2D120XJ00F_SS.pdf Reference for Sharp GP2D120XJ00F Analog Distance Sensor 4-30cm] <br> | ||
[http://luckylarry.co.uk/arduino-projects/arduino-using-a-sharp-ir-sensor-for-distance-calculation/ Arduino – Using a Sharp IR Sensor for Distance Calculation] | [http://luckylarry.co.uk/arduino-projects/arduino-using-a-sharp-ir-sensor-for-distance-calculation/ Arduino – Using a Sharp IR Sensor for Distance Calculation] <br> | ||
[http://benfry.com/writing/map/Table.pde Ben Fry's Table] |
edits