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

DIY Teasing-cat device

Purpose

Cats are animals with strange tempers sometimes, they will run away from you while you want to touch them; and when you want to focus on your work, they just keep annoying you. Thus, I’m gonna make an automatic device with the help of the laser that is able to tease the cats.

Materails

micro:bit x 1

Nezha expansion board x 1

360° servos x 2

Laser module x 1

RJ11 wire x 1

Bricks x n

Assembly steps

Nezha expansion board works with the bricks, let’s make a device in the pictures below:

Hardware Connections

Connect the two servos to S1 and S2 ports, and laser module to J1 ports on the Nezha expansion board.

Software Programming

Go to MakeCode editor:(https://makecode.microbit.org/#editor) Click “Extensions” to add Nezha expansion package.

Search with “Planet X”and download it.

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

Programming

Set to show icon while on start and set the toggle on for the laser module.

Judge the value of S1 and V1 in the forever brick. If S1=V1, set the value of S1 as random among 200~270. If S1<v1, v1=”V1-1,” set=”” the=”” rotation=”” degrees=”” of=”” s1=”” in=”” accordance=”” with=”” value=”” v1;=”” if=””>V1, V1=V1+1, set the rotation degrees of S1 in accordance with the value of V1.</v1,>

Set the rotation degrees of the servo connecting to S2 in the similar way.

Complete Code:

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

Result

After powering it on, the laser module lights up, the two servos move as we programmed, the laser ray moves at random on the floor.

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