mc_workshop

DID IR sensor

May 16th, 2021
550
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. Infrared Proximity Sensor
  3.   July 2020 by MC Workshop e FabiX.
  4.   This example code is in the public domain.
  5. */
  6. const int led = 13;
  7. void setup() {
  8.   Serial.begin(9600);
  9.   pinMode(6, INPUT);
  10.   pinMode(led, OUTPUT);
  11. }
  12. void loop() {
  13.   int s = digitalRead(6);
  14.   if (s) {
  15.     digitalWrite(led, HIGH);
  16.     Serial.println("on");
  17.   } else {
  18.     digitalWrite(led, LOW);
  19.   }
  20. }
RAW Paste Data