"It’s Here! The BFCM Sale of the Year – Grab Your Favorites!"

The Cat Defense Device

Purpose

Make a simple device to get your cat away from it.

I’d love to put this device in my box containing lots of bricks to get my cat away from it as it always carries them in its mouth or plays inside the box, I hope to scare the cat away with the sound and LED bricks.

Materails

micro:bit x 1

Nezha expansion board x 1

Rainbow Led x 1

Sensor x 1

PConnection Diagram

Connect the PIR to J1 port and Led to J2 port on Nehzha expansion board.

Build a device as the picture shows:

Hardware Connections

Step 1

Click “Advanced” to see more choices in the MakeCode drawer.

We need to add a package for programming. Click “Extensions” in the bottom of the drawer and search with “PlanetX” in the dialogue box to download it.

Note: If you met a tip indicating that the codebase will be deleted due to incompatibility, you may continue as the tips say or build a new project in the menu.

Step 2

Code as below

Initialize the rainbow LED to connect the Nonpixel at pin J1 in the on start brick.

While the PIR sensor detects the movement, set to play the music “nyan”, and set the rainbow led to flash in blue and red for 5 times on and on, at last it stops playing the music and the led lights off.

Complete Code:

Link:https://makecode.microbit.org/_408hju8Hsbc7

Result

If the PIR Sensor detects the movement, the Nezha board alarms and the rainbow led flashes for 5 seconds.

Leave a Reply

images
In March, ELECFREAKS supported 5 schools to carry out school science and technology festival activities
images
Children’s Programming Education is the Future Trend
images
Technical verification! Nezha series products can complete WRO competition tasks
images
Let's take part in the Ceremony of the New Factory of ELECFREAKS together!
images
Bluetooth Bee(HC-05 and HC-06) User Guide
images
In March, ELECFREAKS supported 5 schools to carry out school science and technology festival activities
Monthly Archive