Created
August 6, 2014 20:54
-
-
Save afcruz/66844ba31553ba2e0387 to your computer and use it in GitHub Desktop.
Código de ejemplo en Arduino para Sensor de distancia infrarrojo GP2Y0A21
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
/* | |
Código de ejemplo en Arduino para Sensor de distancia infrarrojo GP2Y0A21 | |
http://electronilab.co/tienda/sensor-de-distancia-infrarrojo-gp2y0a21 | |
por Andres Cruz | |
ELECTRONILAB.CO | |
*/ | |
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); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment