Arnov Sharma
Published © LGPL

Motion Trigger Circuit with and without Microcontroller

Simple Tutorial for using HC-SR505 Mini PIR Sensor with and without using a microcontroller

BeginnerFull instructions provided1 hour379
Motion Trigger Circuit with and without Microcontroller

Things used in this project

Hardware components

LILYGO ttgo t display
×1
ATtiny85
Microchip ATtiny85
×1
PCBWay HC-SR505 PIR Sensor
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

TTGO Wiring

Attiny85 Wiring

Simple 01

Simple 02

Code

TTGO Sketch

C/C++
#define sensor 22
#define LED 21
#include <TFT_eSPI.h> // Graphics and font library for ST7735 driver chip
#include <SPI.h>
#define TFT_GREY 0x5AEB // New color

TFT_eSPI tft = TFT_eSPI();  // Invoke library, pins defined in User_Setup.h

void setup()
{
  Serial.begin(9600);
  pinMode(sensor, INPUT);
  pinMode(LED, OUTPUT);
  digitalWrite(sensor, LOW);
  digitalWrite(LED, LOW);
  tft.init();
  tft.setRotation(1);
}
void loop()
{
  tft.fillScreen(TFT_GREY);
  tft.setCursor(4, 10, 2);
  tft.setTextColor(TFT_BLACK,TFT_GREY); 
  tft.setTextSize(2);

  if (digitalRead(sensor)) {
    tft.println("Motion Detected");
    digitalWrite(LED, HIGH);
  }
  else {
    tft.setCursor(4, 10, 2);
    tft.setTextColor(TFT_BLACK,TFT_GREY); 
    tft.setTextSize(2);
    tft.println("No Movement");
    digitalWrite(LED, LOW);
  }
  delay(50);
  
}

Attiny Sketch

C/C++
#define sensor 0
#define LED 1

void setup()
{
  
  pinMode(sensor, INPUT);
  pinMode(LED, OUTPUT);
  digitalWrite(sensor, LOW);
  digitalWrite(LED, LOW);
  
}
void loop()
{
  if (digitalRead(sensor)) {
    digitalWrite(LED, HIGH);
  }
  else {
    digitalWrite(LED, LOW);
  }
  delay(50);
}

Credits

Arnov Sharma
333 projects • 339 followers
Just your average MAKER
Contact

Comments

Please log in or sign up to comment.