How to Control evive’s Buzzer in PictoBlox

Controlling evive's Buzzer in PictoBlox
About This Tutorial
This tutorial discusses what are piezo buzzers, evive’s inbuilt buzzer, how to control it in PictoBlox with the help of a simple program in Stage mode.
Tutorial Info

Components Required

ImageComponentQuantityAvailable in Kit
evive1
USB A-B Cable1

Introduction

A piezo buzzer is an electronic device that is commonly used to produce sound. The working principle behind it is the inverse effect of piezoelectricity. Piezoelectricity or the piezoelectric effect is the ability of certain materials to generate electricity when mechanical pressure is applied to them. This effect was discovered by the French scientist brothers Jacques and Pierre Curie. The word Piezoelectric is derived from the Greek piezein, which means to squeeze or press, and piezo, which is Greek for push.

One of the notable features of the piezoelectric effect is that it is reversible, meaning if an electrical field is applied to the object made of piezoelectric material, mechanical stress is generated, i.e. it either stretches or compresses. This deformation leads to the generation of audible sound.

evive has an inbuilt piezo buzzer. The piezo buzzer is connected to digital pin 46 of Arduino Mega and is controlled via PWM.

evive Peizo Buzzer

How to control evive’s buzzer in Scratch

You can control the buzzer in Scratch with the help of the following block:

  • play tone on () of note () & beat (): This block allows you to control the note sound or the musical note that the buzzer plays and the duration for it plays the specified note. The default pin is set as the pin to which the piezo buzzer connected. You can find this block in the evive palette.

 

Activity: Detecting the Ball

In this activity, we will program evive’s buzzer in such a way that every time the ball touches Tobi, our friendly neighbourhood coding bear, the buzzer will generate a sound.

evive Notes Icon
When working with evive on PictoBlox for the very first time, or if you’ve previously uploaded another code to evive, you must upload the firmware in order to upload new code to it. You can find the procedure for the same HERE.

Follow the steps below to write the script:

Scripts for Tobi

  • Script 1

  1. Connect evive to your computer and open PictoBlox; if already open and working on a project, save that project. Then, click on New.
  2. Go to the toolbar and click on the Board menu. Then select evive as your board. Pictoblox Board Selection
  3. Next, click on the Connect menu and from the fly-out menu, select the Port to which evive is connected e.g. COMXX or ttyXX.Once you select the port, the icon beside the Connect tab will become connected.Connect-Disconnect Icon
  4. Click on the Choose a Backdrop button. Then, select any backdrop of your choice from the backdrop library.Choose Backdrop
  5. Go to the Events palette and drag and drop the when flag clicked block.
  6. Next, go to the Control palette and drag and drop the forever block below the when flag clicked block.
  7. Then, go to the Events palette and drag and drop the broadcast () block and write Ball in the space by selecting New message from the drop-down menu.Broadcast Ball
  8. Go to the Control palette and drag and drop the wait () seconds block below the broadcast () block and write 3 in the space.

Below is the complete script:

Tobi Script 1

  • Script 2

  1. For writing this script, we need to first bring in the ball sprite. For that, click on the Choose a Sprite button and select the ball sprite from the sprite library. In doing so, you’ll notice that the scripting area becomes empty. To continue writing the script, click on Tobi’s icon; you can find it below the stage.New Sprite
  2. Go to the Events palette and drag and drop the when flag clicked block.
  3. Next, go to the Control palette and drag and drop the forever block below the when flag clicked block.
  4. Drag and drop the if block inside the forever block.
  5. Go to the Sensing palette and drag and drop the touching ()? block inside the diamond-shaped space of the if block. Select Ball from the drop-down menu.Touching Ball
  6. Next, go to the evive palette and drag and drop the play tone on () of note () & beat () block inside the if block. The buzzer is the default option. Let the note and beat be the default options; you can change them to any note and beat you like.

Below is the complete script:

Tobi Script 2

  • Script 3

  1. Go to the Events palette and drag and drop the when flag clicked block.
  2. Go to the Motion palette and drag and drop the go to x: () y: () block below the when flag clicked block; set the x and y coordinates as -150 and -110 respectively.
  3. Next, go to the Control palette and drag and drop the forever block below the go to x: () y: () block.
  4. Go to the Looks palette and drag and drop the next costume block inside the forever block.
  5. Then, go to the Control palette and drag and drop the wait () seconds block below the next costume block. Write 0.1 in the space.

Below is the complete script:

Tobi Script 3

Scripts for the Ball

evive Alert
Make sure that the Ball sprite is selected while writing its script.
Follow the steps below to write the script:
  1. Go to the Events palette and drag and drop the when I receive () block; select Ball from the drop-down menu.
  2. Next, go to the Motion palette and drag and drop the go to x: () y: () block below the when I receive () block; set the x and y coordinates as 300 and -120 respectively.
  3. Go to the Looks palette and drag and drop the show block below the go to x: () y: () block.
  4. Go back to the Motion palette and drag and drop the glide () secs to x: () y: () block below the show block. Set the time to 2.5 secs and set the x and y coordinates as -145 and -145 respectively.

Below is the complete script:

Ball script

Click on Tobi and then click on the green flag on the top right corner of the stage to run the script.

Click on the red octagon, next to the green flag to stop the script.

Controlling evive's Buzzer in PictoBlox

Conclusion

It this tutorial, you learned how to control evive’s buzzer in PictoBlox.

Hope you had fun! 🙂

Share this Tutorial
Share on facebook
Facebook
Share on twitter
Twitter
Share on google
Google+
Share on pinterest
Pinterest
Share on reddit
Reddit
Share on print
Print
Related Projects & Tutorials
All articles loaded
No more articles to load
Featured Projects
DIY Color-Sorter
DIY Color Sorter

This project will show you how to make a DIY color sorter using IR sensors and a servo motor.

All articles loaded
No more articles to load

Leave a Reply

Close Menu
×

Cart