Skip to content

Instantly share code, notes, and snippets.

@li2hub
Last active July 10, 2018 15:29
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 li2hub/8d6fa52c8e62f20fc4a56bae2d6bbd42 to your computer and use it in GitHub Desktop.
Save li2hub/8d6fa52c8e62f20fc4a56bae2d6bbd42 to your computer and use it in GitHub Desktop.
void setup()
{
pinMode(13, OUTPUT); // Pin 13 has an LED connected on most Arduino boards
pinMode(2,INPUT); //Pin 2 is connected to the output of proximity sensor
}
void loop()
{
if(digitalRead(2)==HIGH) //Check the sensor output
{
digitalWrite(13, HIGH); // set the LED on
}
else
{
digitalWrite(13, LOW); // set the LED off
}
delay(100); // wait for 100ms
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment