Skip to content

Instantly share code, notes, and snippets.

@tuttelikz
Created March 12, 2018 11:18
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 tuttelikz/562e2ebb221478100b1cd84413b7416d to your computer and use it in GitHub Desktop.
Save tuttelikz/562e2ebb221478100b1cd84413b7416d to your computer and use it in GitHub Desktop.
Snippet to on/off from sensor receiving
const int ProxSensor = 2;
void setup() {
// put your setup code here, to run once:
pinMode(13, OUTPUT);
pinMode(ProxSensor,INPUT);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
if (digitalRead(ProxSensor) == HIGH) {
digitalWrite(13, HIGH);
} else {
digitalWrite(13, LOW);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment