diff --git a/docs/library/pyb.Pin.rst b/docs/library/pyb.Pin.rst
index 576268172d14d872cc97b5c7bea02c440af4e450..010996acf465407592c976c8c4b4e609180d2ff3 100644
--- a/docs/library/pyb.Pin.rst
+++ b/docs/library/pyb.Pin.rst
@@ -55,6 +55,9 @@ an ordinal pin number:
 You can set ``pyb.Pin.debug(True)`` to get some debug information about
 how a particular object gets mapped to a pin.
 
+When a pin has the ``Pin.PULL_UP`` or ``Pin.PULL_DOWN`` pull-mode enabled,
+that pin has an effective 40k Ohm resistor pulling it to 3V3 or GND
+respectively (except pin Y5 which has 11k Ohm resistors).
 
 Constructors
 ------------
@@ -62,7 +65,7 @@ Constructors
 .. class:: pyb.Pin(id, ...)
 
    Create a new Pin object associated with the id.  If additional arguments are given,
-   they are used to initialise the pin.  See ``init``.
+   they are used to initialise the pin.  See :meth:`pin.init`.
 
 
 Class methods
@@ -88,24 +91,6 @@ Class methods
 Methods
 -------
 
-.. method:: pin.__str__()
-
-   Return a string describing the pin object.
-
-.. method:: pin.af()
-
-   Returns the currently configured alternate-function of the pin. The
-   integer returned will match one of the allowed constants for the af
-   argument to the init function.
-
-.. method:: pin.gpio()
-
-   Returns the base address of the GPIO block associated with this pin.
-
-.. method:: pin.high()
-
-   Set the pin to a high logic level.
-
 .. method:: pin.init(mode, pull=Pin.PULL_NONE, af=-1)
 
    Initialise the pin:
@@ -126,10 +111,37 @@ Methods
    
    Returns: ``None``.
 
+.. method:: pin.high()
+
+   Set the pin to a high logic level.
+
 .. method:: pin.low()
 
    Set the pin to a low logic level.
 
+.. method:: pin.value([value])
+
+   Get or set the digital logic level of the pin:
+
+     - With no argument, return 0 or 1 depending on the logic level of the pin.
+     - With ``value`` given, set the logic level of the pin.  ``value`` can be
+       anything that converts to a boolean.  If it converts to ``True``, the pin
+       is set high, otherwise it is set low.
+
+.. method:: pin.__str__()
+
+   Return a string describing the pin object.
+
+.. method:: pin.af()
+
+   Returns the currently configured alternate-function of the pin. The
+   integer returned will match one of the allowed constants for the af
+   argument to the init function.
+
+.. method:: pin.gpio()
+
+   Returns the base address of the GPIO block associated with this pin.
+
 .. method:: pin.mode()
 
    Returns the currently configured mode of the pin. The integer returned
@@ -158,15 +170,6 @@ Methods
    will match one of the allowed constants for the pull argument to the init
    function.
 
-.. method:: pin.value([value])
-
-   Get or set the digital logic level of the pin:
-   
-     - With no argument, return 0 or 1 depending on the logic level of the pin.
-     - With ``value`` given, set the logic level of the pin.  ``value`` can be
-       anything that converts to a boolean.  If it converts to ``True``, the pin
-       is set high, otherwise it is set low.
-
 
 Constants
 ---------
diff --git a/docs/tutorial/debounce.rst b/docs/tutorial/debounce.rst
new file mode 100644
index 0000000000000000000000000000000000000000..f730e1d340e68ce5793f28e247ce877a874285c7
--- /dev/null
+++ b/docs/tutorial/debounce.rst
@@ -0,0 +1,37 @@
+Debouncing a pin input
+======================
+
+A pin used as input from a switch or other mechanical device can have a lot
+of noise on it, rapidly changing from low to high when the switch is first
+pressed or released.  This noise can be eliminated using a capacitor (a
+debouncing circuit).  It can also be eliminated using a simple function that
+makes sure the value on the pin is stable.
+
+The following function does just this.  It gets the current value of the given
+pin, and then waits for the value to change.  The new pin value must be stable
+for a continuous 20ms for it to register the change.  You can adjust this time
+(to say 50ms) if you still have noise. ::
+
+    import pyb
+
+    def wait_pin_change(pin):
+        # wait for pin to change value
+        # it needs to be stable for a continuous 20ms
+        cur_value = pin.value()
+        active = 0
+        while active < 20:
+            if pin.value() != cur_value:
+                active += 1
+            else:
+                active = 0
+            pyb.delay(1)
+
+
+Use it something like this::
+
+    import pyb
+
+    pin_x1 = pyb.Pin('X1', pyb.Pin.IN, pyb.Pin.PULL_DOWN)
+    while True:
+        wait_pin_change(pin_x1)
+        pyb.LED(4).toggle()
diff --git a/docs/tutorial/index.rst b/docs/tutorial/index.rst
index ed1137e1be4909bd3fb6f1c2ddbe667e73f1459f..c134d0deb7f37e89b0ab66106eec579d7b8f0cfa 100644
--- a/docs/tutorial/index.rst
+++ b/docs/tutorial/index.rst
@@ -43,4 +43,5 @@ Tips, tricks and useful things to know
    :maxdepth: 1
    :numbered:
 
+   debounce.rst
    pass_through.rst