element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
microbit
  • Learn
  • Learning Center
  • STEM Academy
  • microbit
  • More
  • Cancel
microbit
micro:bit Blog [PROJECT] BBC Micro:bit – Someone Behind You Sensor - PART 1 - Motion Detection
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join microbit to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Catwell
  • Date Created: 2 Aug 2018 3:23 PM Date Created
  • Views 2176 views
  • Likes 5 likes
  • Comments 1 comment
  • micro:bit
  • project
  • advanced micro:bit projects
  • microbit projects
  • microbit
  • advanced_microbit_projects
  • cabeatwell
  • stem projects
Related
Recommended

[PROJECT] BBC Micro:bit – Someone Behind You Sensor - PART 1 - Motion Detection

Catwell
Catwell
2 Aug 2018

The Someone Behind You Sensor idea (for Arduino) is one of the most useful but simple projects I ever made. I thought it would be worthwhile to port it over to the BBC Micro:bit. The original idea was to have some LEDs placed on a desk, where the user would position the motion sensor in such a way where anyone sneaking up behind them would trigger the LEDs and alert the user to “someone behind them.”

 

It is also a lot of fun for interactive projects. Once you learn how to use one PIR sensor, you can use many. The same with addressable LEDs.

 

Due to the complexity of adding addressable LEDs, I decided to separate this project into two halves. The motion sensing half, and the LED light up half. The LED half is posted as PART 2 here.

 

Now let’s gather all the necessary components you’ll need to build this project.

1x BBC Micro:bit

1x Kitronik Inventor’s Kit

1x PIR Sensor Module

Project Wires Female - Male (aka jumper wires)

9V Power Supply

5V Power Supply with a MicroUSB cable

Construction Paper!

 

 

STEP 1

Lay the Micro:bit and Kitronik Inventor’s Kit on a table. Insert the edge-card end of the Micro:bit into the Inventor’s Kit socket.

imageimage

 

 

STEP 2

Prepare the 9V power supply. I used a 9V power supply from an old device, I think a router. But, there are better versions you could use. Like the one here at element14. You will have to splice the ends into some project wires.

 

STEP 3

Wire up the PIR sensor, as shown in the picture. I used colors to indicate power (RED), ground (BLACK), and the signal (BLUE).

imageimage

 

STEP 4

Attach the PIR sensor’s GND wire to one of the Kitronik Inventor’s Kit breakout pins labeled 0V, that’s a ground. Connect the signal line to the pin labeled P0. This is an analog input.

Follow the schematic below:

image

 

 

Connect the PIR Sensor's signal line to pin A0 on the breakout board.

image

 

 

STEP 5

Connect the 9V power supply’s positive leads to the PIR sensor directly. Then plug the 9V power supply’s ground to another of the Kitronik Inventor’s Kit 0V grounds. To complete a circuit like this, you must share grounds between the power supplies.

A side note: Why do we need to do this? The PIR sensor needs an input voltage of between 5V and 20V, the Micro:bit can only provide a 3.3V source to external devices. Also, Part 2 of the project has addressable LEDs, and we will need a beefy power supply for those.

 

Attach the 9V positive power to the PIR Sensor directly:

image

 

Connect the 9V power supply ground, negative, to the 0V pin on the Inventor's Kit breakout board.

image

 

STEP 6 (Optional)

Roll some construction paper into a tube big enough to house the PIR sensor. Point the white dome of the PIR sensor towards one end of the tube. What this is doing is narrowing the field of view for the PIR sensor. You could leave the PIR sensor outside of the tube, sure, but it has a near 180-degree field of vision. You’ll be triggering it with anyone moving in half the room!

 

imageimage

imageimage

 

 

STEP 7

Plug the MicroUSB cable into the Micro:bit, and plug the other end of the cable to a PC or MAC.

 

At this point, you are going to copy over the code to the Micro:bit. I am providing the program (code) in this posts that needs to be copied over.

I had to pack it up in a ZIP file called Mcode.zip. Unzip it. The file you need is called "microbit motion code.hex"

 

When the Micro:bit plugs into a computer, it shows up as a USB flash drive. All you have to do is copy the file, "microbit motion code.hex," over to the Micro:bit, like it’s a USB Flash Drive.

The Micro:bit will reset, and the program is active.

 

You could leave it plugged into your computer, or use that 5V USB power adapter to make the project a bit more mobile.

 

 

STEP 8

Test it.

 

When the PIR motions sensor is not sensing any motion, there is a sad face on the Micro:bit’s LED screen.

image

 

When it detects someone, it’s happy, and you see a happy face.

image

 

Applications of this project are left to your imagination.

 

Part 2 is coming up next. It will turn this project into an interactive LED light show.

Attachments:
Mcode.zip
  • Sign in to reply

Top Comments

  • neilk
    neilk over 7 years ago +1
    Nice one, Cabe. Neil
  • neilk
    neilk over 7 years ago

    Nice one, Cabe. image

     

    Neil

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube