-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_task.rb
executable file
·66 lines (59 loc) · 1.44 KB
/
main_task.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# main Task
class MainTask
def log(msg)
@logger.write(msg)
end
def initialize
@logger = EV3RT::Serial.new(EV3RT::SIO_PORT_UART)
msg = "main task new\r\n"
log(msg)
end
def execute
colorSensor = EV3RT::ColorSensor.new(EV3RT::PORT_1)
ultrasonicSensor = EV3RT::SonarSensor.new(EV3RT::PORT_3)
touchSensor0 = EV3RT::TouchSensor.new(EV3RT::PORT_3)
touchSensor1 = EV3RT::TouchSensor.new(EV3RT::PORT_4)
leftMotor = EV3RT::Motor.new(EV3RT::PORT_A, EV3RT::LARGE_MOTOR)
rightMotor = EV3RT::Motor.new(EV3RT::PORT_B, EV3RT::LARGE_MOTOR)
armMotor = EV3RT::TailMotor.new(EV3RT::PORT_C, EV3RT::LARGE_MOTOR)
leftMotor.stop
rightMotor.stop
count = 0
while true
# log("count:#{count}")
if count == 401
leftMotor.stop
rightMotor.stop
break
end
case count
when 0..200
leftMotor.power = 10
rightMotor.power = 10
when 201..400
leftMotor.power = -6
rightMotor.power = -6
=begin
armがうまく動かなくて試行錯誤中・・・
when 201..210
leftMotor.stop
rightMotor.stop
# armMotor.power = 1
when 211..220
leftMotor.stop
rightMotor.stop
# armMotor.power = -1
=end
when 401
leftMotor.stop
rightMotor.stop
# armMotor.stop
# log("count=401")
else
end
count+=1
end
log("mruby end")
end
end
MainTask.new.execute