NXT Ultra Sound Sensor (Sonar)

HomeForumsMonoBrick Communication LibraryNXT Ultra Sound Sensor (Sonar)

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #5655
    Author Image
    Ben Huerta
    Participant

    NXT
    I have had good success with the MonoBrick .Net library *except* when trying to use the Ultra Sound (Sonar) sensor. Is there a known bug for this method? I cant seem to get it to work. I get a StackOverFlowException.

    Using Visual Studios 2012

    Code is basically…

    var nxt = new Brick<Sensor, Sensor, Sensor, Sensor>(“usb”);
    string ret = “”;

    // nxt.Connection.Open();

    nxt.Sensor1 = new Sonar();

    ret = nxt.Sensor1.ReadAsString();

    #5656
    Author Image
    Tcm0
    Participant

    I think that just “Read()” could work better.

    #5657
    Author Image
    Ben Huerta
    Participant

    Thanks but I don’t think there is a Read() method.

    #5658
    Author Image
    Ben Huerta
    Participant

    Ok, I got it to work. I switched the connection form USB (“usb”) to Bluetooth (“com6”) <- (my com port, yours may be different depending on your PC connection). I’m not sure what’s going on with the USB connection but this gives me something to focus on.

    Thank you

    #5659
    Author Image
    Tcm0
    Participant

    There is a Read() method according to http://www.monobrick.dk/MonoBrickDocumentation/class_mono_brick_1_1_e_v3_1_1_ultrasonic_sensor.html
    But it’s great that it directly works with bluetooth 🙂

    #5660
    Author Image
    Ben Huerta
    Participant

    Oh I see the confusion. I am using the NXT class and you are referring to the EV3 class. Thanks again for your time with this Tcm0 I truly appreciate it. I’ll check out that method.

    #5661
    Author Image
    Tcm0
    Participant

    Oh, sorry for the confusion. But the NXT class has a mode to read the values as int, too: ReadDistance ()
    http://www.monobrick.dk/MonoBrickDocumentation/class_mono_brick_1_1_n_x_t_1_1_sonar.html

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.

Posted in

Make a donation