Christmas Candies Ejector

Christmas Candies Ejector

Purpose

The Christmas day is coming now! Let’s make a candies ejector to send out candies to Children.

*For a more direct show in the GIF, I’ve changed the trigger of the ejection with the button, actually the project is triggered by the noise sensor.

Materails

micro:bit V2 x 1

Nezha expansion board x 1

Motor x 1

Bricks x n

Assembly steps

The build-up in this picture is a little complicated, here goes the displaying for parts of it only. Do not let our assembly steps limit your own amazing build-up ideas!

1.Side view

Candies holder(Note: please take the size of the holder and the channel into consideration with the candies, the candies in square shape are recommended here)

2.Structure stands

3.Ejection device: here the ejection is made with the elasticity of the device itself.

Hardware Connections

Connect the motor to M1 port on the Nezha expansion board.

Software Programming

Go to MakeCode editor:(https://makecode.microbit.org/#editor)Click “Advanced” in the drawer to see more choices.

Search with “Nezha” in the dialogue box to download it.

Coding

Show icon while on start

Save the variable “i ”as the sound level.

Judge if the variable is over 90.

If yes, set the motor connecting with M1 to rotate at the speed of -100%, and pause with the time given by the formula(1000 plus the mapping value from 90~255 to 0~3000).

IStop the motor.

Complete Code:

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

Result

If the kids come in the front of the device, they will not get the candy with a small voice. If their voice is big enough, the device starts and begins ejecting the candies out. The louder the sound is, the more the candies will be sent out.