91av

Make a remote-control pest-proof bird feeder – part 2

When you add a BBC micro:bit to your bird feeder, you can program it to open when the birds come and shut up shop when pests try to take their food

bird feeder

New stuff you need

You have everything already


LAST week, you put together the body of your electronic bird feeder. In this final instalment of my second maker series, it is time to work on its brain, to allow us to open and close the feeder door.

Using croc clip jumper wires, attach the servo’s brown wire to the BBC micro:bit ground, its red wire to 3V and the yellow to p0. In the MakeCode editor, choose “on button A pressed” from “input”. Clip a “servo write pin p0” into this from the “pins” menu (under “advanced”), typing zero in the box. Power your micro:bit, press A.

Attach the bottle cap arm to the servo shaft so that it covers the bird feeder’s hole. Now, setting the “servo write pin p0” to zero moves the door to the closed position, and “servo write 90” moves the door 90 degrees out of the way.

Let us build on that and write a program to operate the servo when the micro:bit gets a radio signal from another micro:bit, which acts as our remote control.

From “radio” clip “radio set group 1” into “on start”. As we saw in week 8, this sets up a communication channel for the micro:bits. Next, grab “on radio receivedNumber” (also from “radio”). Inside, drop two “if true then” blocks from “logic”. Replace “true” in both with a “0 = 0” comparison from “logic”, then drag and drop “receivedNumber” from the top of the radio block into the first zero in both comparisons. Leave the first as “receivedNumber = 0”, but change the second to “receivedNumber = 1”.

Clip a “servo write pin p0” into each “if” block, typing 0 in the first and 90 in the second. This will close the door when the micro:bit receives “0” via radio, and open the door when it receives “1”.

For the remote control, program the other micro:bit. Add “radio set group 1” to “on start”. Now grab two “on button A pressed” from “input”, changing one to “on button B pressed”. Slot a “radio send number” block into both. Leave the one under button A as “0”, but type “1” into the other. Now, when you press A on the remote micro:bit, it will send 0 to the bird feeder micro:bit, which will close the door. Similarly, press B and 1 is sent, opening the door.

Power up both micro:bits and check they are talking to each other, then slot into your feeder the cardboard piece you made last week. This acts as a shelf for the electronics, with space behind and underneath for nuts. Fill the feeder with peanuts, hang it in the garden and see what animals arrive. You can shut the door to unwanted guests, such as squirrels.

That is it – congratulations, you have completed the second maker series. Keep on making and tweet me your projects.

To download a printable version of this page click here

Starting next week: Stargazing at home

Even if you live in a city with light pollution, there is a lot you can see in the night sky. Abigail Beall, author of , will show you how to spot stars, planets, moons and meteors, learn basic navigation and watch Mercury’s transit of the sun. No telescope required, just a star chart, binoculars and a few other household items.

What you will need in week 1

Cardboard

Two balls

Wire

Sticks

Glue and scissors

Projects so far and a full list of kit required are at
Email: maker@newscientist.com

Topics: Birds / Electronics