;; Jerry Day 4

;; this is all programming by Julie, last modified 1/22/01

to pikasong
note 72 3 note 84 3 note 79 3
end


to scream
note 96 1 note 90 1 note 96 1 note 90 1
note 96 1 note 90 1 note 96 1 note 90 1
note 96 1 note 90 1 note 96 1 note 90 1
note 82 .5 note 81 .5 note 80 .5
end

to runfromlight1
loop [if (sensor 0) < 20 [a, on scream] a, off]
end

to run
left-wheel on thisway
right-wheel on thisway
end

to backup
left-wheel on thatway
right-wheel on thatway
end

to makefastleft
left-wheel on thatway
right-wheel on thisway
end

to makeshortfastleft
left-wheel onfor 5 thatway
right-wheel onfor 5 thisway
end

to makefastright
right-wheel on thatway
left-wheel on thisway
end

to makeshortfastright
right-wheel onfor 5 thatway
left-wheel onfor 5 thisway
end

to slowright
left-wheel on thisway
right-wheel off
end

to slowleft
right-wheel on thisway
left-wheel off
end

to smallslowright
left-wheel onfor 10 thisway
right-wheel off
end

to smallslowleft
right-wheel onfor 10 thisway
left-wheel off
end

to tailwag 
loop[c, onfor 5 thisway
c, onfor 5 thatway]
end

to shorttailwag
repeat 4 [c, onfor 5 thisway
c, onfor 5 thatway]
end



to left-wheel
a,
end

to right-wheel
b,
end

to right-light
output sensor 3
end

to left-light
output sensor 2
end

to follow-light
loop [if (left-light < 50) [left-wheel on]
if (left-light > 50) [left-wheel off]
if (right-light < 50) [right-wheel on]
if (right-light > 50) [right-wheel off]]
end

;; sensors

to left-eye
output sensor 1
end

to right-eye
output sensor 0
end

to rightlight
output sensor 2
end

to leftlight
output sensor 3
end

to taillight
output sensor 4
end

to linesense
output sensor 5
end

to frontbumper
output switch 7
end

to burp
note 40 6
note 42 1
note 43 1
note 47 1
note 50 1
note 55 1
note 60 1
note 70 1
end


to bedrunk
forever [if (frontbumper = 1)
[backup
waituntil [frontbumper = 0]
makeshortfastleft]
]

loop [smallslowright
smallslowleft
burp 
shorttailwag]

end



control buttons =
backup
run
slowright
slowleft
bedrunk
burp
tailwag