I need help coding Ultrasonic Range Finder in robot mesh studio

i have been trying to figure it out on my own but can’t figure it out but i need my robot to stop 6in before a wall

Can you send your code?
Also, is this on V5 or Cortex?

i am using cortex on my robot

Can you send code?

please?

heres what i got because we are doing a drag race with remotes first round and automous for the second
image

Ok, so given the parameters you gave (stop when within 6in of the wall) I would do this:

if(!(ultrasonic distance is < 6)){
(your joystick to motor controls)
}
else{
(stop motors)
}

That’s all sudo-code so obviously it won’t work word-for-word, but that should be the basic structure that you need.

@MostLikelyAHuman could you make this blocky so i and change the button to motor setup or even ss a picture of what you would do on robot mesh studio

Hello.

This program, as written, will evaluate the if conditional once, then reach the end of the program and exit. Probably not what you want.

If you want to run the if over and over, wrap the whole thing in a while True: loop.

Cheers, Sam.

2 Likes