171
edits
Diannamertz (talk | contribs) mNo edit summary |
Diannamertz (talk | contribs) mNo edit summary |
||
Line 1: | Line 1: | ||
=== | ===Need=== | ||
Question: Is there enough flour and sugar at home to make a cake for your friend's birthday tomorrow? Or do you need to stop at the store on your way home? | Question: Is there enough flour and sugar at home to make a cake for your friend's birthday tomorrow? Or do you need to stop at the store on your way home? | ||
Line 9: | Line 9: | ||
* Sharp GP2D120XJ00F Analog Distance Sensor 4-30cm | * Sharp GP2D120XJ00F Analog Distance Sensor 4-30cm | ||
* Container | * Container | ||
* Computer | |||
===Prototype=== | ===Prototype=== | ||
(coming soon) | |||
===Code=== | |||
<source lang="java"> | |||
int IRpin = 1; | |||
int val = 0; | |||
void setup() { | |||
Serial.begin(9600); | |||
} | |||
void loop() { | |||
float volts = analogRead(IRpin)*0.00322265624; | |||
float distance = 12.21*pow(volts, -1.15); | |||
Serial.println(distance); | |||
delay(100); | |||
} | |||
</source> | |||
===References=== | ===References=== | ||
[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] |
edits