Skip to content

Commit fe84c7b

Browse files
author
Romilly Cocking
committed
changed the getting started markdown files to rflect Pi board revision autodetection
1 parent a2b9881 commit fe84c7b

File tree

2 files changed

+8
-30
lines changed

2 files changed

+8
-30
lines changed

doc/getting-started-with-gpio.md

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ the header pin number and whether the pin is to be used for input or
3232
output.
3333

3434
out_pin = Pin(12, Pin.Out)
35-
in_pin = Pin(16, Pin.In)
35+
in_pin = Pin(11, Pin.In)
3636

3737
When you have a Pin instance you can read or write its value. A value
3838
of 1 is high, a value of 0 is low.
@@ -50,7 +50,7 @@ Putting it all together into a single program:
5050
from quick2wire.gpio import Pin
5151

5252
out_pin = Pin(12, Pin.Out)
53-
in_pin = Pin(16, Pin.In)
53+
in_pin = Pin(11, Pin.In)
5454

5555
out_pin.value = 1
5656
print(in_pin.value)
@@ -64,34 +64,20 @@ as part of a [with](http://docs.python.org/reference/compound_stmts.html#with) s
6464

6565
from quick2wire.gpio import Pin, exported
6666

67-
with exported(Pin(12, Pin.Out)) as out_pin, exported(Pin(16, Pin.In)) as in_pin:
67+
with exported(Pin(12, Pin.Out)) as out_pin, exported(Pin(11, Pin.In)) as in_pin:
6868
out_pin.value = 1
6969
print(in_pin.value)
7070

7171
This will unexport the pins when the program leaves the `with` statement, even
7272
if the user kills the program or a bad piece of code throws an exception.
7373

74-
Here's a slightly more complicated example that blinks an LED attached to pin 8. This will
74+
Here's a slightly more complicated example that blinks an LED attached to pin 12. This will
7575
loop forever until the user stops it with a Control-C.
7676

7777
from time import sleep
7878
from quick2wire.gpio import Pin, exported
7979

80-
with exported(Pin(8, Pin.Out)) as pin:
80+
with exported(Pin(12, Pin.Out)) as pin:
8181
while True:
8282
pin.value = 1 - pin.value
8383
sleep(1)
84-
85-
86-
Connecting Pins
87-
---------------
88-
89-
To make this blink program work, you'll need to know which physical pins to connect. The
90-
`quick2wire.gpio` library sorts out the confusion of pin numbering schemes so that you can
91-
just specify the physical pin on the device. [This page](http://elinux.org/Rpi_Low-level_peripherals)
92-
currently seems to be the best summary of the pins and the I/O roles they fulfill. The library
93-
will allow you to allocate only those pins which support GPIO. Lower numbered
94-
pins are at the top end of the Pi with the SD Card and power connector. Pins 1 and 2 (at the top of
95-
the columns) are the 3.3 and 5 volt outputs. Here's a Pi wired up for the blink program
96-
97-
<img src="http://github.com/quick2wire/quick2wire-python-api/raw/master/doc/getting-started-with-gpio-setup.png" alt="GPIO wiring example" width="250"/>

doc/getting-started-with-i2c.md

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,8 @@ Warning:
1010
With a revision 2.0 board, if you connect an I2C device to the appropriate header,
1111
you will see it when you run `i2cdetect 1` instead of `i2cdetect 0`.
1212

13-
Also **in the example below, and in the I2C examples in the examples directory,
14-
you need to change the line**
15-
16-
with i2c.I2CBus() as bus:
17-
18-
to read
19-
20-
with i2c.I2CBus(1) as bus:
21-
22-
We will automate the detection of the default bus as soon as we get our hands on a rev 2.0 board.
13+
The library now auto-detects whether you are running version 1.0 or 2.0 of the board, so the same code will work on
14+
either.
2315

2416
The example:
2517
------------
@@ -46,7 +38,7 @@ group membership.
4638

4739
Check the MCP23008 is connected to your I2C bus and its address is
4840
configured as expected. We can see the device on the bus by running
49-
the `i2cdetect` command:
41+
the `i2cdetect` command. Remember to replace 0 with 1 if you hav a revision 2 board.
5042

5143
$ i2cdetect 0
5244
WARNING! This program can confuse your I2C bus, cause data loss and worse!

0 commit comments

Comments
 (0)