
mgodsell1973

Hi there,
sorry if this is a duplicated post, my tablet appears not to have posted my original.
i am loving my dev kit and learning stacks, but i apart from some Arduino i have not ventured into programming.
what i am looking at is as follows, i currently have an ultrasonic sensor on a servo "scanning" as Traxx moves forwards, however i have noticed that it sometimes it cause a blind spot. so i was thinking by adding a IR sensor constantly facing forward and some coding i could avoid the blind spot by allowing the EZ-B to "decide" which sensor to listen too, depending upon distance.
thanks
Code:
i have been playing with the code above and trying to work out the best way to have the ez b read the two sensors.
i understand that after the "if" and "else if" funtions i need to add a command, however i believe that i need to put a function in thats says
repeatUntil(1=2) #repeat forever
$ping=GetPing(D0,D1) #Read ping sensor
$IR=getADC(adc0) # Read the IR sensor, value increases as distance decreases
If($ping>20, $IR<20) = if the ping is greater than 20 Cms and the $IR sensor is less than 20cms
i want it to read the IR sensor and then use the Movement Panel avoid the object
endif
sleep(100)
endrepeatUntil
but i can't find the code to put the Movement Panel back in control?
regards and thanks once again
*stress*
So if I have this correct you have one ping sensor and one IR sensor?
If so the code you need will be similar to below (modify to suit your requirements and sensors)...
Code:
You nearly had the IF statement correct. Think of IFs logically, you wanted to have two values meet the requirements... so IF the ping is more than 20 AND the IR is less than 20. If you wanted it to be true if ping is more than 20 or ir is less than 20 use the OR expression.
Movement panel controls are;
Code:
Look them up in the EZ-Script manual for their parameters.
Anyway.... I kinda' feel bad this break has still got you rattled, though....
Am I right in thinking that by adding the forward command in, its like telling the system to revert back to scanning when moving forward until the ping sensor/ir sensor detects an object?
Code:
Provided somewhere in the script before the whole ping/ir checking process you have a Forward() then ending the checking with a Forward() will make the robot avoid an object then continue on it's way.