We really like this review of the basics via raspi.tv and hope you do, too!
It struck me the other day that I’ve published some fairly advanced RPi.GPIO tutorials, (e.g. interrupts and PWM) but not done anything more basic, apart from the Gertboard examples. So here’s an attempt to remedy that situation.
Over the next few days, we’re going to have a walk around Ben Croston’s RPi.GPIO, which is now at version 0.5.3a. Some of this stuff may be new to you even if you’ve been using RPi.GPIO’s more advanced features, so it’s worth having a look.
Part 1: “how to check what RPi.GPIO version you have” starts out with:
It’s quite useful to be able to find out what version of RPi.GPIO you have. Some features require a recent version, whereas others work with older versions. For example, interrupts were added at 0.5.1, PWM at 0.5.2 and with 0.5.3 some bugs have been squashed.
You don’t have to write or run any programs to find out which version you have. You can do it very quickly in a live Python session. If you don’t know how to do that, it’s a great way of testing things out in Python.
Get started with Part 1 here.
Part 2: “how to check what Pi board Revision you have” follows up with:
It all started in September 2012. The Raspberry Pi Foundation went and made some improvements to the Pi. How dare they!! 😉 Seriously, though, there were some significant improvements to the Pi and a Rev 2 version was launched with double the RAM and some other changes/additions/improvements.
This threw up some minor headaches for developers because some of the GPIO pinouts were changed and some new GPIO ports were made available on a brand new “solder it yourself if you want it” header called P5 (see the leaning header of Pi5a)
GPIO 0 became GPIO 2 (P1 pin 3)
GPIO 1 became GPIO 3 (P1 pin 5)
GPIO 21 became GPIO 27 (P1 pin 13)
The two i2c buses were swapped around:
SDA0 became SDA1 (P1 pin 3 alternative function)
SCL0 became SCL1 (P1 pin 5 alternative function)
Some new GPIO ports 28, 29, 30, 31 were made available if you solder on P5 header.
Read Part 2 here.
RPi.GPIO provides a built-in function GPIO.cleanup() to clean up all the ports you’ve used. But be very clear what this does. It only affects any ports you have set in the current program. It resets any ports you have used in this program back to input mode. This prevents damage from, say, a situation where you have a port set HIGH as an output and you accidentally connect it to GND (LOW), which would short-circuit the port and possibly fry it. Inputs can handle either 0V (LOW) or 3.3V (HIGH), so it’s safer to leave ports as inputs.
Read Part 3 here.
Well, today is the day we actually get to use RPi.GPIO a little bit. But, before we get to that, you should know about the two different numbering systems you can use with RPi.GPIO.
If you take a look at the main GPIO header (P1) of the Raspberry Pi, you’ll see that there are 26 pins. The top left pin (as we look at this photo) is called pin 1, the one to the right of it is pin 2. So the next row is 3, 4 etc. and on down to 25, 26. This is how pin headers are numbered.
Check out Part 4 here!
Each Friday is PiDay here at Adafruit, be sure to check out our posts, tutorials and new Raspberry Pi related products. Have you tried the new “Adafruit Raspberry Pi Educational Linux Distro”? It’s our tweaked distribution for teaching electronics using the Raspberry Pi. But wait, there’s more! Try our new Raspberry Pi WebIDE! The easiest way to learn programming on a Raspberry Pi.
We now have Raspberry Pi Model B with 512MB RAM in stock and shipping now!
Have an amazing project to share? Join the SHOW-AND-TELL every Wednesday night at 7:30pm ET on Google+ Hangouts.
Join us every Wednesday night at 8pm ET for Ask an Engineer!
Learn resistor values with Mho’s Resistance or get the best electronics calculator for engineers “Circuit Playground” – Adafruit’s Apps!
Maker Business — State of the live streaming’ Facebook, YouTube, Twitch and now Twitter (Periscope)
Wearables — Defeat UV discoloration
Electronics — Steady Headers
Biohacking — Are There Any Proven Benefits to Fasting?
No comments yet.
Sorry, the comment form is closed at this time.