精品导航

Let's get movin'!

In this chapter, we'll learn how to code your Wheelson's motors to go forward or backward, or to move the wheels in place.

This seems like a lot of work, but don't worry.

To begin, find this I/O block labeled "When button left pressed" and drop it on the drawing area.



Let's change the "left" to "up".

Now we'll code what happens to each motor when you click the button.

To do that, find this I/O block:



Make sure the speed value for this button is set to 10.

Repeat this for all four motors.



So, what we did here is we coded your Wheelson to move forward once the Up button is pressed.

Another thing we'd like to do is turn on the headlights.

For that, you'll need this I/O block:



Let's see what happens when we release the button we're holding.



We want the motors to stop and the headlights to turn off once we release the button.

Find these two blocks and place them within the "When button up released" block to do this.



Let's do it again for three more pushbuttons: down, left, and right.

When we press the "down" button, we want the Wheelson to start moving backward and that's why we need to add the minus sign before the speed value.

We also want to turn on the headlights.



We want the motors to stop and the headlights to switch off when we release the button in question.



So we coded the back and forth movement.

Let's code moving the wheels in a place.

We'll do that with right and left buttons.



We must set two of the motors to move backward and two to go forwards in order for Wheelson to move in place.

As always, turn the headlights on.

When we release the right button, we want the motors to stop working, and the headlights to turn off.



Repeat the process for the left button, but make sure to make different motors going back and forth.



The final step is to include the block that determines what happens when the left button is released.



Finally, we must include the "loop forever" block with the "scan buttons" inside it to guarantee that the buttons are always scanned and that the code is executing properly.

Please remember to include this section every time you code something with the buttons.

Click on the Run button and try it out.




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