Lesson 69: Infrared Proximity Sensor E18-D80NK | Arduino Step-by-Step Course
In this lesson, we learn how to use the infrared proximity sensor E18-D80NK with Arduino. The module is explained, the wiring diagram is shown, and wiring is explained. The code is fully explained and demonstrated.
Ak kód nie je viditeľný, zobrazte si túto stránku v angličtine. Ospravedlňujeme sa za nepríjemnosti.
456-Lesson 69: Infrared Proximity Sensor E18-D80NK | Arduino Step-by-Step Course
Jazyk: C++
/*
* S08-01
* Lesson 69: Proximity Sensor E18-D80NK with Arduino
* This is the Arduino code for E18-D80NK Infrared Obstacle Avoidance Sensor.
This code is to use E18-D80NK Infrared Sensor to detect obstacles and trigger an
event like starting or stopping a motor, servo, relay, or anything else.
Watch instruction video for this code: https://youtu.be/bu0LHgXq7Pw
* *
// Written by Ahmad Shamshiri for Robojax.com on
// February 22, 2018 at 20:50 in Ajax, Ontario, Canada
* Disclaimer: this code is "AS IS" and for individual educational purposes only.
*
This video is part of Arduino Step by Step Course which starts here: https://youtu.be/-6qSrDUA5a8
If you found this tutorial helpful, please support me so I can continue creating
content like this.
or make a donation using PayPal http://robojax.com/L/?id=64
* This code is "AS IS" without warranty or liability. Free to be used as long as you keep this note intact.*
* This code has been downloaded from Robojax.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
The wiring:
Brown: 5V DC
Blue: GND
Black: Signal, to PIN 2
*
*/
#define SENSOR 2 // define pint 2 for sensor
#define ACTION 9 // define pin 9 as for ACTION
/*
* Permission granted to share this code given that this
* note is kept with the code.
* Disclaimer: this code is "AS IS" and for educational purposes only.
*
*/
void setup() {
// E18-D80NK Obstacle Sensor Code by Robojax.com 2018022
Serial.begin(9600);// setup Serial Monitor to display information
pinMode(SENSOR, INPUT_PULLUP);// define pin as Input sensor
pinMode(ACTION, OUTPUT);// define pin as OUTPUT for ACTION
}
void loop() {
// E18-D80NK Obstacle Sensor Code by Robojax.com 2018022
int L =digitalRead(SENSOR);// read the sensor
if(L == LOW){
Serial.println(" Obstacle detected");
digitalWrite(ACTION,HIGH);// send signal
}else{
Serial.println(" === All clear");
digitalWrite(ACTION,LOW);// turn the relay OFF
}
delay(500);
// E18-D80NK Obstacle Sensor Code by Robojax.com 2018022
}
Zdroje a referencie
Zatiaľ žiadne zdroje.
Súbory📁
Žiadne súbory nie sú k dispozícii.