Code
|
Handy Board 1 | Handy Board 2 |
Handy
Board 1
to race
race-song
when [(sensor 0) > 70]
[a, onfor .5 wait 3]
when [(sensor 1) > 70]
[b, onfor .5 wait 3]
waituntil [ (sensor 2) > 60 ]
stoprules
a, off
b, off
wait 20
forever [congratulate]
wiggle
d, onfor 70 rd
stoprules
wait 25
go-back
a, rd
b, rd
end
to go-back
a, rd on waituntil [sees-white? 5] off
b, rd on waituntil [sees-white? 6] off
d, onfor 70 rd
end
to sees-white? :which-sensor
output ((sensor :which-sensor) < 100)
end
to wiggle
c, onfor 1
c, rd repeat 30 [onfor 2 rd]
c, onfor 1
c, off
end
to congratulate
Note 87 2 Note 89 2 Note 91 2 Note 92 4
Note 87 6 Note 92 2 Note 91 2 Note 92 2
Note 94 4 Note 89 6 Note 89 2 Note 91 2
Note 92 2 Note 96 2 Note 94 2 Note 94 2
Note 92 2 Note 92 2 Note 91 2 Note 89 2
Note 91 2 Note 92 10
end
to race-song
forever [
chorus
play_note 92 3
play_note 87 1
chorus
play_note 92 3
repeat 2 [play_note 87 .5]
repeat 3 [play_note 92 1]
repeat 2 [play_note 87 .5]
repeat 2 [play_note 92 1]
play_note 92 2
repeat 2 [play_note 92 .5]
play_note 92 1
repeat 2 [play_note 92 .5]
play_note 92 1
repeat 4 [play_note 92 .5]
repeat 2 [play_note 92 1]
chorus
play_note 92 4
]
end
to chorus
repeat 3 [play_note 92 1]
play_note 87 1
repeat 2 [play_note 89 1]
play_note 87 2
repeat 2 [play_note 96 1]
repeat 2 [play_note 94 1]
end
to play_note :frequency :duration
if ((sensor 2) < 70)
[Note :frequency :duration]
end
<< Top
Handy
Board 2
to block
forever [a, on waituntil [sees-white? 1] rd
waituntil [sees-white? 2] rd]
forever [b, on waituntil [sees-white? 5] rd
waituntil [sees-white? 6] rd]
waituntil [ (sensor 0) > 20 ]
stoprules
a, off
b, off
wait 300
cookie
stoprules
end
to sees-white? :which-sensor
output ((sensor :which-sensor) < 50)
end
to cookie
c, onfor 9 rd
wait 100
onfor 8 rd
end
<< Top