Skip to content

Instantly share code, notes, and snippets.

@afcruz
Created August 6, 2014 20:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save afcruz/66844ba31553ba2e0387 to your computer and use it in GitHub Desktop.
Save afcruz/66844ba31553ba2e0387 to your computer and use it in GitHub Desktop.
Código de ejemplo en Arduino para Sensor de distancia infrarrojo GP2Y0A21
/*
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