Luc Paquin
Published © CC BY-NC

Project #28 – Sensors – PIR – Mk23

Project #28 – Sensors – PIR – Mk23

BeginnerFull instructions provided1 hour63
Project #28 – Sensors – PIR – Mk23

Things used in this project

Hardware components

Wemos D1
×1
DFRobot Gravity: I2C 16x2 Arduino LCD
×1
Elecrow Crowtail- PIR Motion Sensor 2.0
×1
USB Battery Pack
×1
DFRobot Micro USB Cable
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Fritzing

Code

DL2601Mk01p.ino

Arduino
/****** Don Luc Electronics © ******
Software Version Information
Project #28 – Sensors – PIR – Mk23
28-23
DL2601Mk01p.ino
DL2601Mk01
1 x Wemos D1
1 x Gravity: I2C 16x2 Arduino LCD
1 x Crowtail- PIR Motion Sensor 2.0
1 x USB Battery Pack
1 x Micro USB Cable
*/

// Include the Library Code
// Wire
#include <Wire.h>
// LCD1602 RGB Module
#include "DFRobot_RGBLCD1602.h"

// LCD1602 RGB Module
/*RGBAddr*/
/*lcdCols*/
/*lcdRows*/
// 16 characters and 2 lines of show
DFRobot_RGBLCD1602 lcd(0x60 , 16, 2);

// PIR motion sensor
// Use pin 2 to receive the signal from the module  
#define PIR_MOTION_SENSOR  D2
int sensorValue;
String sPIR = "";

// Software Version Information
String sver = "28-23";

void loop() {
  
  // PIR
  isPIR();

  // isDisplayPIR
  isDisplayPIR();

  // Delay
  delay( 1000 );
  
}

getDisplay.ino

Arduino
// getDisplay
// Gravity: I2C 16x2 Arduino LCD
// Display UID
void isDisplayUID(){

  // Set up the LCD's number of rows and columns: 
  // Print a message to the LCD.
  // Cursor
  lcd.setCursor(0, 0);
  lcd.print("Don Luc Electron");
  // Cursor
  lcd.setCursor(0, 1);
  // Print a message to the LCD.
  lcd.print( sver );

}
// Display PIR
void isDisplayPIR(){

  // Clear
  lcd.clear();
  // Set the cursor to column 0, line 0
  lcd.setCursor(0, 0);
  lcd.print( "PIR" );
  // Set the cursor to column 0, line 1
  lcd.setCursor(0, 1);
  lcd.print( sPIR );
  
}

getPIR.ino

Arduino
// PIR motion sensor
// is PIR
void isPIR(){

  // PIR
  sensorValue = digitalRead(PIR_MOTION_SENSOR);

  // If the sensor value is HIGH?
  if(sensorValue == HIGH)
	{
		
    // Yes, return true
    sPIR = "True";

	}
	else
	{
		
    // No, return false
    sPIR = "False";


	}

}

setup.ino

Arduino
// Setup
void setup()
{
 
  // Delay
  delay( 100 );

  // PIR motion sensor
  pinMode(PIR_MOTION_SENSOR, INPUT);

  // Delay
  delay( 100 );

  // PIR motion sensor
  lcd.init();

  // Delay
  delay( 100 );

  // Display UID
  // Don Luc Electronic
  // Version
  isDisplayUID();

  // Delay 5 Second
  delay( 5000 );

}

Credits

Luc Paquin
77 projects • 5 followers
Teacher, Instructor, E-Mentor, R&D and Consulting -Programming Language -Microcontrollers -IoT -Robotics -Machine Learning -AI -Sensors

Comments