Загрузка...

Arduino Tutorial #13: How to use Photo Interrupter with Arduino , ( 9 of 37 Sensor Kit)#arduino

@DIY_Arduino_Projects
Full Video: https://youtu.be/_JwEeDH-W9A

Arduino Tutorial #13: How to use Photo Interrupter Sensor with Arduino UNO, (9 of 37 Arduino Sensor Kit).
-----------
CODE
------------
/*
This is 9 of 37 Sensors Tutorial code
NOTE: Please replace $ sign with open and close Angle brackets in the code below, because YOUTUBE won't let me include angle brackets in video's Description.
*/
#include $LiquidCrystal_I2C.h$ //In this line Please replace $ sign with open and close Angle brackets

//connections SDA--A4 and SCL--A5
//initialize the liquid crystal library
//the first parameter is the I2C address

LiquidCrystal_I2C lcd(0x27, 16, 2);

int SensorPin = 8;
int ledPin = LED_BUILTIN;
int state = 0;

void setup() {

lcd.init(); //initialize lcd screen
lcd.backlight(); // turn on the backlight
pinMode(ledPin, OUTPUT);
pinMode(SensorPin, INPUT);
}

void loop() {
delay(100);
state = digitalRead(SensorPin);
lcd.clear();
lcd.setCursor(0, 0); //write on the top row
lcd.print("Sensor Data: ");
lcd.print(state);
if (state == LOW) {
digitalWrite(ledPin, LOW);

} else {
digitalWrite(ledPin, HIGH);
lcd.setCursor(0, 1); //write on the bottom row
lcd.print("Object Detected");
}
}

Hope this tutorial was useful. Please hit LIKE for more Arduino tutorial and subscribe to stay tuned.
#arduino #arduinouno #arduinoproject #diy #diyprojects #arduinotutorial #linetracking #linetrackingsensor

Видео Arduino Tutorial #13: How to use Photo Interrupter with Arduino , ( 9 of 37 Sensor Kit)#arduino канала Arduino Projects
Яндекс.Метрика

На информационно-развлекательном портале SALDA.WS применяются cookie-файлы. Нажимая кнопку Принять, вы подтверждаете свое согласие на их использование.

Об использовании CookiesПринять