{"id":954,"slug":"python-io-on-rpi","title":"Python IO on rPi","excerpt":"My next \u0026lsquo;real\u0026rsquo; project involves implementing a web interface to control some of the things around swan tron global HQ, the half of the garage I …","content":"\u003cp\u003eMy next \u0026lsquo;real\u0026rsquo; project involves implementing a web interface to control some of the things around swan tron global HQ, the half of the garage I reserved for my lab. I\u0026rsquo;ve been a huge fan of the Raspberry Pi since the mission was announced. Linux and IO\u0026hellip;you have my attention. Add in the $35 price tag and my penchant for destroying hardware\u0026hellip;huge fan is correct. Before I start planning my real project, I need to figure out how this differs from the microcontrollers I\u0026rsquo;ve used in the past to deal with similar implementations. I know the CPU is going to show itself, but not to what extent. Time to start poking around. I decided to horse around and knock out a few birds with one stone\u0026hellip;python library, digital out, and basic pin function. Oh, and LEDs. Everyone loves LEDs. \u003cimg src=\"/uploads/2013/01/cobbler.jpg\" alt=\"the 80s called, they want their printer cable back\"\n  loading=\"lazy\"\n  decoding=\"async\"\n/\u003e\n Prior to this effort, I have mainly explored the rPi via x. I\u0026rsquo;ve spent a decent amount of time inspecting the file structure (Debian, no surprises) and the xwin UI. It is no speed demon, but it does the trick. I have the wireless adapter configured and set to auto-start, which was most of the battle. It basically performs as advertised, which on paper is very awesome for the price. My general setup for this was very simple. I bought a cobbler set from Adafruit, which acts simply to pull the IO pins out to a breadboard. Two LEDs, two resisters. A few jumpers. Very simple. I booted the device, and used aptitude to update and snag the rPi GPIO library. \u003cstrong\u003esudo apt-get update****sudo apt-get install python-rpi.gpio\u003c/strong\u003eThat does the heavy lifting with the python implementation\u0026hellip;sample code is available \u003ca href=\"http://pypi.python.org/pypi/RPi.GPIO\"\u003eon the main python site\u003c/a\u003e. The update was I used vim to create a dirty python script\u0026hellip;unworthy of a repository, but worth a pic: \u003cimg src=\"/uploads/2013/01/dirty_code.jpg\" alt=\"fugly code\"\n  loading=\"lazy\"\n  decoding=\"async\"\n/\u003e\n The digital outs worked as anticipated. Timing was a bit odd\u0026hellip;I ended up playing around a bit with some pauses in order to tune the blinks as I wanted. It looks like coordinating pin outs might be tricky for more complex operations, but at least the library and hardware is up and running. Don\u0026rsquo;t take my word for it: \u003ciframe allowfullscreen=\"\" frameborder=\"0\" height=\"315\" src=\"https://www.youtube.com/embed/xV6204QqH2w\" width=\"560\"\u003e\u003c/iframe\u003eThe next steps will be interesting. Figuring out how to ssh into the box in order to run a script of this magnitude will be next, followed by profiling the voltage on the pinout. It should be able to throw my 5v relay with a little tweaking\u0026hellip;if not I\u0026rsquo;ll figure out PWM and tackle the switching mechanically. Fun stuff to come\u0026hellip;happy to be playing with the rPi finally. Stay tuned.\u003c/p\u003e\n","date":"2013-01-09T17:01:52Z","permalink":"https://swantron.com/2013/01/09/python-io-on-rpi/","link":"https://swantron.com/2013/01/09/python-io-on-rpi/","path":"/2013/01/09/python-io-on-rpi/","featuredImage":"/uploads/2013/01/cobbler.jpg","categories":[],"tags":[]}