Shop OBEX P1 Docs P2 Docs Learn Events
Question for Mike about code. — Parallax Forums

Question for Mike about code.

MovieMakerMovieMaker Posts: 502
edited 2009-08-02 18:13 in Robotics
Hey, Mike!

· If you are watching, I have been trying to convert lines of PBASIC into C++ code for the robot I am currently working on. I have learned a lot, but apparently not enough. For my Boe-bot, I would write something like this for the subroutine:


Raise_Brows:
for i=1 to 40
PULSOUT browservo,600
next
Pause 500
RETURN

Now, I cannot find a PULSOUT command in my version of C.

Is there away around this with some other C command?

Thanks for your wonder help in the past.· Also, I welcome Anyone to answer this question, but I know that Mike will know the answer. Thank You All.

:-)

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-08-02 03:21
    The answer is:

    You can't find a PULSOUT command in your version of C because there isn't any such thing in C or C++ unless someone (the vendor) has provided a library function to do it. For that matter, there's normally no timing capability in C either, so you can't have a PAUSE.

    How you might do something like this depends on your C or C++ system and what you're running the program on (and you didn't supply any of that ... makes it really hard to help).
  • kwinnkwinn Posts: 8,697
    edited 2009-08-02 03:21
    Re: "Raise_Brows:"

    Are you planning a remake or the next chapter of "Short Circuit"?
  • MovieMakerMovieMaker Posts: 502
    edited 2009-08-02 03:27
    I'm sorry. I am running the Arduino on an xp system. I figured you would just tell me that it is not supported on this forum. But,·my post·IS about robotics.

    Kwinn,

    The raised brows are very cool. A johnny five robot is already available. I think as a finished product and as a kit. But, I like mine better. (it costs less.)

    I plan in the future to possibly use the BasicStampII,PX24,PE,Propeller and two arduinos in one machine. But, I need to learn C.

    Post Edited (MovieMaker) : 8/2/2009 2:34:01 PM GMT
  • FranklinFranklin Posts: 4,747
    edited 2009-08-02 17:10
    Try the Arduino site http://arduino.cc·and check out the tutorials and the playground. Everything you need is there.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen

    Post Edited (Franklin) : 8/2/2009 10:12:24 PM GMT
  • Mike GreenMike Green Posts: 23,101
    edited 2009-08-02 17:35
    It's actually arduino.cc/.

    You'll find library routines "delayMicroseconds" and "digitalWrite" which you can use together to do what PULSOUT does and "delay" does what PAUSE does.
  • P!-RoP!-Ro Posts: 1,189
    edited 2009-08-02 17:48
    I've been working with C on the pic recently, but I'm not sure how close it is to your C++. On the Pic in C I would use

    while(1 == 1) // loop forever
    {
    for(i = 0; i < servopulse; i++) // make pin high for the correct pulse length
    {
    servopin = 1;
    }

    for(i = 0; i < twentymstime; i++) // make pin low for 20ms
    {
    servopin = 0;
    }
    } // loop again to top

    For the constants twentymstime, servopulse, and servopin you will need to put in the correct numbers to make it function. Also note I am fairly new to C, so this may not be the best way to get the job done.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    PG
  • MovieMakerMovieMaker Posts: 502
    edited 2009-08-02 18:13
    Franklin and Mike, I have been there.



    Pi, your language looks Exactly like mine. Also Arduino version 17 is going to include PULSOUT. Yeh!





    Thank You guys sooo much!

    smile.gif

    Post Edited (MovieMaker) : 8/2/2009 6:18:19 PM GMT
Sign In or Register to comment.