[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


c++  VS.  python:   hardware control.

Posted on 2007-07-20
Medium Priority
Last Modified: 2013-12-27
my electronics class almost touched using computer to control hardware, but we ran out of time.   it was to be powered by and controlled through a COM port (like the old mouse port, remember?)  and DC motors and lights could be operated through that.

my question is though, the python.org headline picture shows a lot of electronics and stuff, I am wondering though,  is c++ better at controlling "simple"  stuff like DC motors , or maybe today python can do some of those as well?

I'd love to initiate hardware controls from python than c++ ( and i don't care if I am not as powerful, it's just easier to learn)

I guess my question is actually, how to start hardware stuff with python, or rather, how to start hardware design.
Question by:Troudeloup
LVL 30

Expert Comment

ID: 19537676
python has no access to hardware
c and c++ can thats why a lot of apps are written in c
LVL 15

Expert Comment

ID: 19538864
You can do whatever you want from python.

True you don't control memory addresses in python, but (a) usually it's not needed as you have hardware control through devices like COM-port which are easily accessible via file interface and
(b) python 2.5 has direct native dll access (ctypes module) which allow you access anything (ctypes is also available for earlier version of python).

In your case it should be extremely easy: type some char to COM to start/stop the motor.

Accepted Solution

doraemon-nolife earned 2000 total points
ID: 19562766
Python cant do the control on hardware directly.

However, you can call python from C program or call C program from python program. It is some sort like JNI in java.

Check these link, it might be useful to you.

Extending and Embedding python interpreter

Python/C API

:) Good Luck

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
The viewer will learn how to implement Singleton Design Pattern in Java.
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
Suggested Courses
Course of the Month19 days, 7 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question