*********************************************
* UPDATED: CODE *
*********************************************
Hello! I have 2 years exprience in programming before i doned this.
Now i show this to you because i want to know does it work.
Sensor thingy is my own maked i tell more later.
I debugged the code and it worked. It uses Tri-state motor controlling, check nuumio's tip about it!
'Obstacle avoider with sound
symbol sensor = 4 'sensor pin
symbol turn = 1200 'how much to turn
symbol speaker = 2 'speaker pin
symbol motorR = 1 'right motors pin
symbol motorL = 0 'left motors pin
symbol light = b1
tune speaker, 4,($40,$42,$80,$44,$46,$04,$04,$04) 'play starting tune
main:
'start motors
high motorR
high motorL
readadc sensor,light 'reads sensor
if light < 100 then goto main
'if light high = detects object
avoid:
low motorR
low motorL
'motors low
tune speaker, 3,($00,$02,$00,$02,$00)
dirs = %00000011
'go backwards and play sound
pause 1000 '1 second
high motorL 'then turn to right
pause turn '1,2 seconds
goto main 'go back to main
There it was,hope it works!