Learn How to Use VIA Pixetto to Build a Face Detection Alarm

Hello everyone! For this project, we will show you how to make an alarm
buzzer using VIA Pixetto vision sensor, a piezo buzzer, and an Arduino
board. With the help of AI technology and Pixetto’s face detection
function, the finished face detection alarm will buzz when the vision
sensor detects a face. This project is not only fun to make, but can also
be used as a buzzer alarm.

Alright, let’s get started!

The guide will involve seven simple steps:

Step 1: Installing expansion board to an Arduino board
Step 2: Connecting piezo buzzer to an Arduino board
Step 3: Connecting the VIA Pixetto to a PC
Step 4: Configuring the VIA Pixetto
Step 5: Connecting VIA Pixetto to an Arduino board thru expansion board
Step 6: Programming VIA Pixetto with blocks
Step 7: Uploading the code to the Arduino board

Step 1

We need to attach the expansion board onto the Arduino board via pin
header connectors.

Step 2

The piezo buzzer is a device that can generate basic tones and beeps.

First, connect the Grove cable to the piezo buzzer.

face detection buzzer

Then, attach the piezo buzzer to the Grove connector labeled D4 on the
expansion board, which in turn is attached to the Arduino board.

Step 3

You will need to connect your VIA Pixetto to your PC using a Micro USB
2.0 cable.

When you see that the green, blue and red LEDs are lit, this means the
VIA Pixetto is successfully connected.

Do not forget to remove the lens cover.

Step 4

Open the VIA Pixetto Utility and configure the VIA Pixetto to detect faces
by selecting the Face Detection function.

face detection

When you are finished configuring the VIA Pixetto, you can test it to make
sure it can detect faces.

test the face detection function

Step 5

First, connect the Grove cable to the VIA Pixetto vision sensor.

face detection

Then, attach the other end of the Grove cable to the Grove connector
labeled ‘UART’ on the expansion board, which is in turn attached to the
Arduino board.

face detection

Step 6

Open the VIA Pixetto Junior application and build the blocks for face
detection which would activate the piezo buzzer.

A. First layer of blocks

Select the first layer from the Control category, which is the ‘setup
block, then add the ‘initialize vision sensor’ block from the Vision Sensor
category.

This block will relate information to VIA Pixetto.

face detection

Place the ‘initialize vision sensor’ block within the setup block.

Lastly, select pins 0 for RX, and pin 1 for TX. ‘RX’ means receive and ‘TX’
means transmit.

This makes sure there is a connection between the Arduino board and
VIA Pixetto.

Note: We recommend using pins 0 and 1 for optimal reliability.

B. Second layer of blocks

Now, we create the blocks which makes the piezo buzzer emit sounds.

The first step is to select the ‘If () Then’ block from the Control category
to create an event.

Then, from the Vision Sensor category, select an ‘object is detected
block and put it inside the ‘If () Then’ block. This makes VIA Pixetto
report that it is detecting an object (face) using a command from the
Arduino board.

The block inside is ‘object is detected’. If this condition is true, the block inside will activate the event.

To make this true, use another ‘If () Then’ block again to create an event.
This will allow the VIA Pixetto to detect any faces.

Insert the second ‘If () Then’ block into the first ‘If () Then’ block to create
an event. This will allow the VIA Pixetto to detect an object (face).

Next, select a ‘logic’ block from the Logic category. Then, select the
object type’ block and ‘0’ block from the Vision Sensor category.

Insert an ‘object type’ block and ‘0’ block into the ‘logic’ block. Then, set
the ‘logic’ block to equal sign.

blocks for face detection

Put the ‘logic’ block inside the ‘If () Then’ block.

Next, from the ‘Inout’ category, select the ‘emits sound on pin () in
frequency (Hz) () for a time (ms) ()
’ block.

Set the pin to pin 4 because the piezo buzzer is connected to Grove
connector D4. Set the sound frequency (Hz) value to 4000, and then
the time (ms) value to 100. The time (ms) value determines how long the
piezo buzzer will play the 4,000Hz sound.

Note: The input values for frequency and time depend on use preference.

Insert the ‘emits sound on pin () in frequency (Hz) () for a time (ms) ()
block into the second ‘If () Then’ block. This block makes sure that when
the VIA Pixetto reports it has detected an object (face), the Arduino
board will command the piezo buzzer to emit a sound with the given
frequency and amount time.

frequency for face detection buzzer

Next, add a ‘delay ()’ block. Select the ‘delay ()’ block from the Control
category.

Set the ‘delay ()’ block to 100 milliseconds. The ‘delay ()’ block will
provide a delay between each sound emitted by the piezo buzzer (the
delay time can be adjusted according to personal preference).

Put the ‘delay ()’ block into the second ‘If () Then’ block underneath the
emits sound on pin () in frequency (Hz) () for a time (ms) ()’ block.

From the Control category, select the ‘repeat while ()’ block. Then, select
the ‘object is detected’ block from the Vision Sensor category.

These blocks means the piezo buzzer will continuously emit sounds as
long as the VIA Pixetto detects faces.

VIA Pixetto face detection sounds

Insert the ‘object is detected’ block into the ‘repeat while ()’ block.

Lastly, put the ‘repeat while ()’ inside the second ‘If () Then’ block
underneath the ‘delay ()’ block.

face detection

Review the composed blocks and make sure they are in order. Double
check the pins, the frequency, and the time values to make sure they are
correct.

If the pins are incorrectly selected within the different blocks, the piezo
buzzer may not emit sounds when it detects a face.

face detection blocks

Step 7

After completing and reviewing the blocks, upload the code to the
Arduino board.

A. How to connect the Arduino board to PC

First, connect the Micro USB 2.0 cable to the PC using a USB 2.0/3.0 port.
Then, connect the other end of the cable to the Micro USB 2.0 port on
the Arduino board.

B. How to upload the code

Click the ‘No Hardware’ dropdown arrow on the top of the VIA Pixetto
Junior app, then select ‘Arduino UNO’ to start establishing the connection.

face detection

Then click on the ‘Not Connected’ dropdown arrow, a pop-up screen will
be displayed. Click the ‘Connect’ button to establish the connection.

You can use the refresh button if the USB connection is not found on the
PC. The COM port should be set to COM9 (Note: The COM port may vary
depending on your PC’s configuration).

Once connected, click on the ‘Go to Editor’ button to go back to the VIA
Pixetto Junior application.

Click on the ‘Upload’ button on the right side of the VIA Pixetto Junior
app to upload the code to the Arduino board.

Wait to see the ‘Upload Success’ message before unplugging the cable.

C. How to save your project

We can save our project after we have uploaded the code to the Arduino
board.

First, click on the icon next to ‘Project’ to open its scrolling menu and
select ‘Save Project As’.

When we click on ‘Save Project As’. A Save As window will pop-up on
screen. We can name the project and create or find a suitable folder to
save our project.

Now that we have connected the VIA Pixetto vision sensor, attached the
piezo buzzer, and uploaded the code to the Arduino board, it is time to
do some test runs. Just point your VIA Pixetto at a person’s face to see if
the alarm sounds. (Note: you can make your own outer case for your face
detection alarm to protect the individual project components).

And we are done! We have successfully used VIA Pixetto’s face
recognition abilities and a piezo buzzer to create a smart alarm that
buzzes when it sees a human face.

Have fun with this project and don’t forget to share your own blocks
creations with us on Instagram at #VIAPixetto!

Share this blog post!

Share on linkedin
Share on twitter
Share on facebook

Leave a Reply