Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I followed these instructions successfully, so I was able to get the Raspberry Pi to send "HELLO\n" to my Arduino Mega 2560 over USB and print to Serial console.

I have installed Open CV successfully on my Raspberry Pi using these steps and successfully tested camshiftdemo.c with my web camera on the pi.

Now I would like to execute camshiftdemo on the pi and get it to send "TURN LEFT\n" or "TURN RIGHT\n" strings to a 4-wheel rover. The rover is attached to my Arduino Mega 2560.

So basically, Raspberry Pi runs camshiftdemo.c, tracks an random object of user's choosing. Then camshiftdemo draws an ellipse around the chosen object as it is moving. If the object drifts to the left side of the web camera, the Raspberry Pi sends "TURN LEFT\n" to the arduino, causing the wheels of rover to turn left. If the object drifts to the right side of the web camera, the Raspberry Pi sends "TURN RIGHT\n" to the arduino, causing the wheels of the rover to turn right.

The camshiftdemo code is written in C and the first link above shows how to use Python to send simple ASCII commands to an arduino over USB. How do I combine camshiftdemo.c and Python to work together? Specifically, how can I modify "camshiftdemo.c" to execute python code from the C program?

Would greatly appreciatea all / any advise.

share|improve this question

closed as off topic by Leon Heller, Dave Tweed, Olin Lathrop, Brian Carlton, embedded.kyle Nov 13 '12 at 21:12

Questions on Electrical Engineering Stack Exchange are expected to relate to electronics design within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

    
Jim Paris is right. Embedding Python for this task is a little overkill. You can just send ASCII over USB from straight C. However, if you are interested in embedding Python in C for whatever reason, have a look at some of the tutorials I linked to in this answer over on SO. – embedded.kyle Nov 13 '12 at 12:57
2  
Where is the electrical engineering problem? – Olin Lathrop Nov 13 '12 at 13:51
    
Although the question says USB, Jim's answer below rightly suggests the serial APIs, as the Arduino's USB interface is one which the host operating system will treat as a serial port. – Chris Stratton Feb 6 '13 at 18:50
up vote 3 down vote accepted

You should just send the serial commands from C. No need to embed a Python interpreter. For all the information you might need on the topic, see the excellent Serial Programming Guide for POSIX Operating Systems.

Also, this question is off topic for this particular site.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.