Skip to content

Instantly share code, notes, and snippets.

@HectorTorres
Created May 5, 2017 20:47
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 HectorTorres/61a9e54f3d15824c2e1ebfab40dc941f to your computer and use it in GitHub Desktop.
Save HectorTorres/61a9e54f3d15824c2e1ebfab40dc941f to your computer and use it in GitHub Desktop.
Sensor inductivo NPN
int pin=13; //declaras un pin digital
void setup()
{
pinMode(pin,INPUT); //declaras el pin digital como entrada
Serial.begin(9600);
}
void loop()
{
if (digitalRead(13)==HIGH) //condición si el pin digital esta en estado alto te mostrara un 1 si no un 0
{
Serial.println(1);
}
else
{
Serial.println(0);
}
delay(1000); //tiempo en mili segundos de cada muestreo
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment