Forum | Documentation | Website | Blog

Skip to content
Snippets Groups Projects
Commit 24a4e9f6 authored by Mark Yoder's avatar Mark Yoder Committed by Robert Nelson
Browse files

Playing with group-tabs in chapter 2

parent 9a649c0e
No related merge requests found
...@@ -306,24 +306,30 @@ is wired to one of the seven analog-in ports (*P9_36*). ...@@ -306,24 +306,30 @@ is wired to one of the seven analog-in ports (*P9_36*).
Wiring a 10 |kohm| variable resistor (trimpot) to an ADC port Wiring a 10 |kohm| variable resistor (trimpot) to an ADC port
:ref:`sensors_analogIn_code` shows the code used to read the variable resistor. :ref:`py_analogIn_code` shows the code used to read the variable resistor.
Add the code to a file called _analogIn.js_ and run it; then change the resistor and run it again. The voltage read will change. Add the code to a file called *analogIn.py* and run it; then change the resistor and run it again. The voltage read will change.
.. _py_analogIn_code: .. tabs::
.. literalinclude:: ../code/02sensors/analogIn.py .. group-tab:: Python
:caption: Reading an analog voltage (analogIn.py)
:linenos:
:download:`analogIn.py <../code/02sensors/analogIn.py>` .. _py_analogIn_code:
.. _sensors_analogIn_code: .. literalinclude:: ../code/02sensors/analogIn.py
:caption: Reading an analog voltage (analogIn.py)
:linenos:
.. literalinclude:: ../code/02sensors/analogIn.js :download:`analogIn.py <../code/02sensors/analogIn.py>`
:caption: Reading an analog voltage (analogIn.js)
:linenos: .. group-tab:: JavaScript
.. _sensors_analogIn_code:
:download:`analogIn.js <../code/02sensors/analogIn.js>` .. literalinclude:: ../code/02sensors/analogIn.js
:caption: Reading an analog voltage (analogIn.js)
:linenos:
:download:`analogIn.js <../code/02sensors/analogIn.js>`
.. note:: .. note::
...@@ -386,22 +392,27 @@ as shown in :ref:`sensors_ultrasonic_fig`. The device outputs ~6.4 mV/in when po ...@@ -386,22 +392,27 @@ as shown in :ref:`sensors_ultrasonic_fig`. The device outputs ~6.4 mV/in when po
:ref:`py_ultrasonicRange_code` :ref:`py_ultrasonicRange_code`
shows the code that reads the sensor at a fixed interval. shows the code that reads the sensor at a fixed interval.
.. _py_ultrasonicRange_code: .. tabs::
.. literalinclude:: ../code/02sensors/ultrasonicRange.py .. group-tab:: Python
:caption: Reading an analog voltage (ultrasonicRange.py)
:linenos:
:download:`ultrasonicRange.py <../code/02sensors/ultrasonicRange.py>` .. _py_ultrasonicRange_code:
.. _sensors_ultrasonicRange_code: .. literalinclude:: ../code/02sensors/ultrasonicRange.py
:caption: Reading an analog voltage (ultrasonicRange.py)
:linenos:
:download:`ultrasonicRange.py <../code/02sensors/ultrasonicRange.py>`
.. literalinclude:: ../code/02sensors/ultrasonicRange.js .. group-tab:: JavaScript
:caption: Reading an analog voltage (ultrasonicRange.js)
:linenos:
:download:`ultrasonicRange.js <../code/02sensors/ultrasonicRange.js>` .. _sensors_ultrasonicRange_code:
.. literalinclude:: ../code/02sensors/ultrasonicRange.js
:caption: Reading an analog voltage (ultrasonicRange.js)
:linenos:
:download:`ultrasonicRange.js <../code/02sensors/ultrasonicRange.js>`
.. _sensors_hc-sr04: .. _sensors_hc-sr04:
...@@ -536,21 +547,27 @@ The *2* after the *qep* returned by *show-pins* shows it's *eQEP2*. ...@@ -536,21 +547,27 @@ The *2* after the *qep* returned by *show-pins* shows it's *eQEP2*.
Finally, add the code in :ref:`digital_rotaryEncoder_py` Finally, add the code in :ref:`digital_rotaryEncoder_py`
to a file named *rotaryEncoder.py* and run it. to a file named *rotaryEncoder.py* and run it.
.. _digital_rotaryEncoder_py: .. tabs::
.. literalinclude:: ../code/02sensors/rotaryEncoder.py .. group-tab:: Python
:caption: Reading a rotary encoder (rotaryEncoder.py)
:linenos:
:download:`rotaryEncoder.py <../code/02sensors/rotaryEncoder.py>` .. _digital_rotaryEncoder_py:
.. _digital_rotaryEncoder_js: .. literalinclude:: ../code/02sensors/rotaryEncoder.py
:caption: Reading a rotary encoder (rotaryEncoder.py)
:linenos:
.. literalinclude:: ../code/02sensors/rotaryEncoder.js :download:`rotaryEncoder.py <../code/02sensors/rotaryEncoder.py>`
:caption: Reading a rotary encoder (rotaryEncoder.js)
:linenos: .. group-tab:: JavaScript
.. _digital_rotaryEncoder_js:
.. literalinclude:: ../code/02sensors/rotaryEncoder.js
:caption: Reading a rotary encoder (rotaryEncoder.js)
:linenos:
:download:`rotaryEncoder.js <../code/02sensors/rotaryEncoder.js>` :download:`rotaryEncoder.js <../code/02sensors/rotaryEncoder.js>`
Try rotating the encoder clockwise and counter-clockwise. Try rotating the encoder clockwise and counter-clockwise.
You'll see an output like this: You'll see an output like this:
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment