×

SparkFun Electronics will be closed on July 3rd, 2015 in observance of Independence Day. Any orders placed after 2:00pm MT on July 2nd will be shipped out after the weekend. Thanks!

avatar

oscarvs

Member Since: October 5, 2012

Country: Venezuela

  • To get centimeters:

    int i;
    int val;
    int redpin=0;
    void setup() {
        pinMode(redpin,OUTPUT);
        Serial.begin(9600);
    }
    void loop() {
        i=analogRead(redpin);
        val=(6762/(i-9))-4;
        Serial.println(val);
    }