Shop OBEX P1 Docs P2 Docs Learn Events
PING DAR on Activity Bot — Parallax Forums

PING DAR on Activity Bot

raoramanaraoramana Posts: 9
edited 2014-11-10 17:49 in Robotics
Hi Guys

Any one tried this on an Activity Bot? It seems like a difficult task bec of the lack of support for sub routines in C. Any thoughts?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2014-11-09 09:58
    What do you mean by "lack of support for sub routines in C"? C has all sorts of support for subroutines. In C you declare a subroutine as a function with a "void" result type like:

    void foobar(void) {
    // do stuff
    }

    If you want parameters, you put those instead of the 2nd "void" like:

    void foobar( int stuff, int *moreStuff) {
    // do stuff
    }

    PING DAR should be easy to do. There's a version of FemtoBasic for the Activity Board and a translation of Roaming With PING into FemtoBasic. PING DAR isn't as complicated a program.

    Here's the link for the Activity Board FemtoBasic.
  • dgatelydgately Posts: 1,628
    edited 2014-11-09 10:25
    raoramana wrote: »
    It seems like a difficult task bec of the lack of support for sub routines in C. Any thoughts?

    Yeah, what Mike said...

    Attached is a version of the spin kickstarter example project (link: http://learn.parallax.com/KickStart/28015) code in C as a SimpleIDE project. It is in SimpleIDE's ZIP format. I used spin2cpp to quickly convert the project from spin to C. Should be a fairly simple task to add-in Ping))) Dar functions...

    Oh, and functions don't always return a void type...
    int myFunction(int someInt) {
    // do something really cool, here!
    }
    

    Is a perfectly suitable function that takes an integer and returns an integer!


    dgately
  • raoramanaraoramana Posts: 9
    edited 2014-11-10 17:45
    Thanks Mike. Stay warm!
  • raoramanaraoramana Posts: 9
    edited 2014-11-10 17:49
    Thanks. Will give it a try.
Sign In or Register to comment.