A problem with sensors

i have an issue with the sensors in vex v5 c++. i set the sensor up in robot view but when i try to use it, it always returns 0. Any help is appreciated

What kind of sensor is it?

i have tried both an ultrasonic and a line sensor

Ah, I haven’t used those sensors with the V5, so I can’t help. Hopefully, someone who has can give you some troubleshooting tips.

how do you set the sensors up? some examples of your code would be helpful for us to help

i set it up in robot view, i connected the output wire to A and the input wire to B, than i went into main and did this Brain.Screen.print(Sonar1.distance(distanceunits::cm));

try swapping the wires around

i did and it did nothing

Did you only try to print it once, or did you put it in a loop?

i tried both bot neither worked

Try Brain.Screen.print("%f",Sonar1.distance(distanceunits::cm)); instead?

I have this issue as well. Might just be my brain but any sensor I plug into 3-wire ports always returns 0. I see this in the “devices > 3-wire” menu on the brain and when I try to print out the values.

did you ever fix it?

No, we were just using potentiometers, so with a little math we can just use the integrated encoders in v5 motors. I would’ve liked to use an ultrasonic for our claw, but we were able to go without it.

oh i will try on our other brain