;; rover.lsp -- the Rover keeps moving by avoiding obstacles ;; ;; Port A: motor for the left wheel of the Rover ;; Port C: motor for the right wheel of the Rover ;; Port 2: touch sensor for obstacle detection ;; ;; Contributor(s): Taiichi Yuasa (begin (speed :a (speed :c (speed :b :max-speed))) (write-string "Press Prgm button to start") (wait-until (pressed?)) (wait-until (not (pressed?))) (let loop () (motor :a (motor :c :forward)) (motor :b :off) (play '((:Re4 . 2) (:Do4 . 1) (:Re4 . 1) (:Fa4 . 1) (:Re4 . 1) (:Re4 . 2) (:Fa4 . 2) (:So4 . 1) (:Do5 . 1) (:La4 . 2) (:Re4 . 2))) (wait-until (or (touched? 2) (pressed?))) (if (pressed?) (motor :a (motor :c :off)) (begin (motor :a (motor :c (motor :b :back))) (sleep 5) (motor (if (= (random 2) 0) :a :c) :forward) (sleep 5) (loop)) ) ) )