×

SparkFun Electronics will be closed in observance of memorial day on Monday, May 29th. We will resume normal business hours on Tuesday, May 30th. Any orders placed after 2pm Mountain Time on Friday, May 26th will process and ship out on Tuesday, May 30th.

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);
    }