Microbit: Someone comes & sense and blink

Overview
In this project you will learn how to control the LED – 3W LED Module (ON/OFF) while PIR Motion Sensor detects motion/activity, our aim is to learn the motion sensor, and how we can utilize it.

You may see such a lens in a film or television. When someone wants to attack a target, but is not close to the target, they were directly found and the alarm sounded. When some special forces go to the target, they will be covered with moist mud, so that they will not be discovered by the other party. Why?

Originally, the human body will emit a certain wavelength of infrared rays of about 10um. The relevant sensors are installed near the targets that are being attacked to sense the infrared rays emitted by the human body and then alarm them. After the mud is applied, the sensors can not sense the infrared rays emitted by the human body.

Component Required

  • Micro:bit main board*1
  • Keyestudio Micro bit Sensor V2 Shield*1
  • USB Cable*1
  • Keyestudio PIR Motion Sensor*1
  • Keyestudio 3W LED Module*1
  • Dupont jumper wire*3

Component Introduction
Keyestudio 3W LED Module:
This LED module is of high brightness because its lamp beads are 3w. You can apply this module to Arduino or other projects, ideal for Robot or search and rescue application.

For example, intelligent robots can use this module for illumination purposes.
Please note that the LED light can’t be exposed directly to human eyes for safety concerns.

361-4.png

Specifications (3W LED Module)

  • Color temperature: 6000~7000K
  • Luminous flux: 180~210lm
  • Current: 700~750mA
  • Power: 3W
  • Light angle: 140 degree
  • Working temperature: -50~80℃
  • Storage temperature: -50~100℃
  • High-power LED module, controlled by IO port of the microcontroller
  • IO Type: Digital
  • Supply Voltage: 3.3V to 5V

Specifications (PIR Motion Sensor)

  • Input Voltage: 3.3 ~ 5V, Maximum for 6V
  • Working Current: 15uA
  • Working Temperature: -20 ~ 85 ℃
  • Output Voltage: High 3V, Low 0V
  • Output Delay Time (High Level): About 2.3 to 3 seconds
  • Detection Angle: 100°
  • Detection Distance: 3 meters
  • Output Indicator LED (if output is HIGH, it will be ON)
  • Limit Current for Pin: 100mA

Connect It Up

Insert the micro:bit into keyestudio micro:bit sensor V2 shield. Then connect PIR Motion Sensor to micro:bit sensor shield, connect the S pin0 to S pin header, + pin to V1 header, – pin to the ground header. And then connect 3W LED module to micro:bit sensor shield, connect the S pin1 to S pin header, + pin to V1 header, – pin to the ground header.

DBFamily vlogs
You can also visit our youtube channel for even more interesting videos at the following link.
https://www.youtube.com/@dbfamilyvlogs

GitHub Repo:
You can access the code repo at GitHub at the following link.
https://github.com/dbcoder14/project-16-someone-comes-pir-motion-sensor

Javascript code block

let sensor = 0
basic.clearScreen()
basic.forever(function () {
    sensor = pins.digitalReadPin(DigitalPin.P0)
    if (sensor) {
        basic.showNumber(pins.digitalReadPin(DigitalPin.P0))
        pins.analogWritePin(AnalogPin.P1, 1023)
        basic.pause(5)
        pins.analogWritePin(AnalogPin.P1, 41)
        basic.pause(500)
    } else {
        basic.showNumber(0)
        pins.analogWritePin(AnalogPin.P1, 0)
        basic.pause(500)
    }
})

Python code block

sensor = 0
basic.clear_screen()

def on_forever():
    global sensor
    sensor = pins.digital_read_pin(DigitalPin.P0)
    if sensor:
        basic.show_number(pins.digital_read_pin(DigitalPin.P0))
        pins.analog_write_pin(AnalogPin.P1, 1023)
        basic.pause(5)
        pins.analog_write_pin(AnalogPin.P1, 41)
        basic.pause(500)
    else:
        basic.show_number(0)
        pins.analog_write_pin(AnalogPin.P1, 0)
        basic.pause(500)
basic.forever(on_forever)

makecode.microbit.org

Hope you will enjoy the project, see you in the next post.
Abdulsamad & Abdulraheem

Author: Danyal
I'm skilled programmer with expertise in Vue.js/Nux.js for front-end development and PHP Laravel for back-end development. I excel in building APIs and services, and also have experience in web server setup & maintenance. My versatile skill set allows you to develop and maintain web applications effectively, from the user interface to the server-side functionality. I love coding with never ending learning attitude, thanks for visiting danya.dk