找回密码
 马上注册

QQ登录

只需一步,快速开始

查看: 3063|回复: 0

Robotc for EV3 虚拟世界任务五

[复制链接]
发表于 2020-9-16 14:40:44 | 显示全部楼层 |阅读模式

14、任务:F
orward Until Touch

前进,直到停止。
1600236593(1).jpg

  1. task main()
  2. {
  3.     while(getTouchValue(S1) == 0)
  4.     {
  5.         setMotorSpeed(motorB,100);
  6.         setMotorSpeed(motorC,100);
  7.     }
  8. }
复制代码

运行结果:

forward_until_touch20209161415221.gif




15、任务:Try It:Forward Until Touch

练习用的,没有任务
1600237062(1).jpg



16、任务:Vacuum

接触四面墙壁
1600236993.png

  1. task main()
  2. {
  3.         repeat(4)
  4.         {
  5.                 while(getTouchValue(S1) == 0)
  6.         {
  7.                 setMotorSpeed(motorB,100);
  8.                 setMotorSpeed(motorC,100);
  9.         }

  10.                 setMotorSpeed(motorB,-100);
  11.                 setMotorSpeed(motorC,-100);
  12.                 sleep(600);
  13.                 setMotorSpeed(motorC,0);
  14.                 resetMotorEncoder(motorB);
  15.                 setMotorTarget(motorB,400,100);

  16.                 waitUntilMotorStop(motorB);


  17.         }

  18. }
复制代码

运行结果:
Vacuum20209161429502.gif


欢迎一起交流:





如果您觉得我的帖子对您有用,请不吝给我一个“赞”!
您需要登录后才可以回帖 登录 | 马上注册

本版积分规则

QQ|手机版|中文乐高 ( 桂ICP备13001575号-7 )

GMT+8, 2024-4-26 20:37 , Processed in 0.173014 second(s), 21 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表