Last active
May 20, 2018 16:35
-
-
Save penpencool/043423103db9342f4a994d483c8a1eae to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Example By ArduinoAll | |
VCC -> 5V | |
GND -> GND | |
Vo -> A0 | |
*/ | |
int IRpin = A0; // ต่อเซนเซอร์กับขา A0 | |
void setup() { | |
Serial.begin(9600); | |
} | |
void loop() { | |
float volts = analogRead(IRpin) * 0.0048828125; // value from sensor * (5/1024) - if running 3.3.volts then change 5 to 3.3 | |
float distance = 65 * pow(volts, -1.10); | |
Serial.println(distance); | |
delay(100); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment