Programming with hardware in python [closed]

别来无恙 提交于 2019-11-30 10:27:09

问题


I am starting to get a bit bored of programming little toys that I have been making recently, and I would love to starting programming and interacting with hardware.

The only problem is that I am mostly a python guy who hasn't really learned or used any other language. Can I still interact with hardware with python?

Also, what hardware can I interact with? I don't really have stuff lying around that I can use, so I would have to buy a kit or something. What are some cheap options for this?


回答1:


Interacting with the serial port on a PC is fairly trivial and there is Python Serial library available. The roomba robot is controllable via a serial port. There are probably other robots out there, but this might be a simple, smallish step to get you going.

Personally, I learned a lot by buying a PIC programmer and making some simple circuits to flash LEDs. I moved on to controlling those PICs via serial port and later using USB (via libusb). There's a bigger learning curve there as you'll have to program the PICs in C or assembler but you can achieve some pretty incredible results once you've picked up the basics. I warn you though, it's a slippery slope once you realise how many cool little gadgets you can build :-)




回答2:


Definitely look at Arduino.

  • The hardware design is open-source so you could even assemble your own if you wanted
  • The board includes digital and analog inputs and outputs so it's easy to get some LEDs flashing quickly
  • You program it in a 'language' called Wiring which hides a lot of complexities of C which is usually used on PICs

On the PC side, you could then use pySerial to communicate with the board over USB as mentioned above




回答3:


The new Raspberry Pi devices have a good range of I/O and Python seems to be the most commonly used language for them.




回答4:


try BugLab or OpenMoko




回答5:


You can use ctypes for interfacing with hardware. It'll let you call into native libraries, so you can essentially use it to do anything that C can do. This is of course assuming that you want to interact with hardware via your host computer running Python.

I've used ctypes for a couple of projects:

  • Controlling Keyboard LED on OS X to show morse code
  • Creating USB/HID user-land driver for a response box

I found it generally pretty easy to use, but it helped that I already knew C/C++.




回答6:


Buy a Lego Mindstorm kit. The programming language is easy to live with -- it isn't Python -- but it's close enough. And they're real robots with real actuators and sensors.




回答7:


Many pc's still have parellel ports, and a python module exists for interacting with the parallel port, though I haven't used it.

The parallel port may be the simplest way to start controlling hardware, as you can attach the simplest of electronics to it. Just an led will get you something visible straight away.

Then, as Jon Cage mentions, you could get a Pic programmer




回答8:


The SNAP wireless nodes at www.synapse-wireless.com run a subset of Python called SNAPpy. You can use the peek() and poke() built-ins in the SNAPpy language to interact directly with hardware inside the chip (PWM for example). SNAPpy also has built-ins for I2C, SPI, and serial, so you can control external hardware. It also has built-ins for lower level I/O too, like readPin() writePin() and readAdc(). Something like an EK2500 kit might be good to start with. See also the online user forum at forums.synapse-wireless.com




回答9:


I'm not too sure anyone has mentioned the BASIC stamp. Again - it is very limited, but its SUPER simple to start working with. There are some other processors up there they make too, but as an introductory - I think its a great device.

Arduino too is a good one, and you can probably get more bang for you buck with that device.

As mentioned above, I got my start on PIC processors - which are not the easiest thing to work with initially (or really ever... haha - its debateable), but I got a great understanding of how things work in the world of micro controller / hardware interaction.

Best of luck & if you have any questions, feel free to ask away!



来源:https://stackoverflow.com/questions/919857/programming-with-hardware-in-python

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!