精品导航

Sound on

Let's learn what to do with the Piezo buzzer that's soldered onto your 四房热播.

As the word itself says, the buzzer is used for making buzzing sounds. 

We'll make a very similar sketch to the last one, but this time, pressing the buttons will trigger a particular sound to come out of the buzzer.

Let's start!

Go to the display block section and choose the "fill frame with" block.

random image



Now we'd like to write the instructions that are shown as soon as we press the Run button.

We'll need the "write string" block for that. You can find it here:

random image
random image



We'll make the background white and write "Press the buttons" in black, as shown in the image above.

We don't want to forget about the "push frame" block.
Amazing! You can test your code by clicking Run, and then proceed with the sketch and change what happens when a particular event is triggered.
When you press 四房热播's buttons, we trigger a particular event.
As we learned in the previous chapter, a specific block defined for that can be found under the I/O section.
The first block from the I/O section we'll use is "when left pressed".

random image



Drag and drop it under the instructions part of the code. 

random image



This time, we want a buzzer to make a specific sound and draw one of the shapes from the first chapter.

To do so, we'll need to begin with another I/O block, "play tone (0,0)".
This block will be used to specify the frequency and duration of our sound.

random image



Drag it into the I/O block, change the frequency to 1000 Hz, and play it for 200 milliseconds.

random image



Amazing! 

Let's try something similar to what we did in the previous example.
Because we'll be drawing something on the screen, we'll need to fill the screen with the particular color, which you can do by locating the "fill frame" block.

random image
random image



We must now decide what we want to draw, whether it will be filled or outlined, and where we want it to be drawn.

We can do that using this block: 

random image
random image



We chose to draw a 6x6 filled red rectangle at the coordinates 40x50.

Finally, at the end of this block, insert the "push frame" block.

random image



Before we can test whether pressing this specific button causes the desired event, we must first find the "loop forever" block to ensure that your buttons are being scanned at all times. Please remember to use this every time you code something with the buttons, or it will not work.

The "loop forever" button can be found here:

random image



Drag and drop it on the drawing area and look for the I/O "scan buttons" block:

random image
random image



You can now test everything by pressing the Run button and then clicking on left button.

When you press that button, your screen should look like this, and you should hear a sound from your 四房热播:
Now, just like in the previous sketch, we'll duplicate this for the three more buttons and change them slightly.
To begin, double-click the I/O block that says "when left pressed" to duplicate everything inside it.

random image



This new I/O block will alter what happens when we press the right button.
Now, we'll play the sound at 2000 Hz for 200 milliseconds.

At the same time, we'll draw a 6x6 blue-filled rectangle with coordinates 40x50 on a yellow background.
To see what happens, click the Run button and then the left button on your 四房热播:
Let's do it again with another button.

random image



This time, we'll trigger the event pressing the enter button.

The sound will play at 100 Hz for 150 milliseconds, and we will draw a 6x6 yellow-filled rectangle on a purple background with coordinates 40x50.
To see what happens, click the Run button and then enter:
Finally, we'll repeat this process for the back button.

random image



The sound will play for 50 milliseconds at 3000 Hz, and we will draw a white filled rectangle 6x6 in the coordinates 40x50 on the marron background.

Now that you know how to make sounds and draw different things, you can experiment with the buzzer and the display.

友情链接:久久爱 | 蘑菇网页版入口 | 蘑菇影视 | 青青伊人 | 蓝色导航 | 资源导航 | 天天综合 | 玖玖爱 | tissu-premier.com | 琳琅导航 | 蘑菇tv网页版 | 小蓝视频 | gzdksw.com | p站视频 | jxty00.com | 日本高清 | 久久久久久 | 午夜在线观看 | 欧美午夜 | 色妞 | 青草草 | 樱花视频 | 导航大全 | 永久地址 | sanzhucare-zhpg.com | 天堂在线 | 五月丁香 | 玖玖资源站 | 摩天轮社区 | 六月婷婷 | hebeijiaoyuwang.com | 宅男影院 | dna0126.com | fltou.com | zhuoyemall.com | 久久香蕉 | 蘑菇在线观看网页版 | 最新av | 小草社区 | 蘑菇传媒在线观看 | mogus.cc | 色婷婷 | 老司机视频 | 性知音 | 青草青青 | zpzb2008.com | 福利盒子 | 在线亚洲 | mogu视频 | mogutv | 第一福利 | 无名网 | 汤姆影院 | 五福影院 | 蘑菇传媒 | 迷妹网 | 亚洲精品 | 伊人色 | 秋霞网 | 精品免费 | 老王影院 | 亚洲网 | 超碰视频 | 蘑菇app | tsxhyq.com | 福利精品 | 屁屁影院 | rencai98.com | 在线午夜 | 蘑菇视频网站 | 色啪 | 四虎影视 | 琵琶妞 | 永久网站 | 蘑菇短视频入口 | 扒哥黑料 | 蘑菇网 | 酒色世界 | 红桃视频 | woqidz.com | 龙物视频 | 蜜芽视频 | 蘑菇视频ios | 番号网 | bt搜索 | 久久视频 | 青娱 | 看片神器 | mogu | 4008108885.com | 蘑菇視頻 | dk99999.com | 协和影院 | btupic.com | 秋霞影院 | 草莓视 | 蘑菇视频入口 | 综合影院 | lf397.com