From 4ab9a70eeca834c3474b27f67f3e06538bb5d643 Mon Sep 17 00:00:00 2001
From: "Mark A. Yoder" <Mark.A.Yoder@Rose-Hulman.edu>
Date: Fri, 20 Sep 2024 16:00:26 -0400
Subject: [PATCH] Switched back to correct blinkLED.rst

---
 intro/beagle101/blinkLED.rst | 259 +++++++++++++----------------------
 1 file changed, 97 insertions(+), 162 deletions(-)

diff --git a/intro/beagle101/blinkLED.rst b/intro/beagle101/blinkLED.rst
index be04d6f3..8b2d521e 100644
--- a/intro/beagle101/blinkLED.rst
+++ b/intro/beagle101/blinkLED.rst
@@ -16,93 +16,91 @@ Here we'll show you how to do just that in three simple steps.
 These steps will work for any of the Beagles.
 
 Plug in the Beagle
-------------------
+*******************
 
 For this step you need to get a USB cable and attach your Beagle 
 to your host computer with it.  Where you attached the cable 
 depends on which Beagle you have.  Click on the tab for your board.
 
-.. tabs::
+.. tab-set::
 
-    .. group-tab:: Black
+    .. tab-item:: Black
 
         .. figure:: figures/image8.jpg
             :width: 632px
-            :height: 166px
             :align: center
             :alt: Tethered Configuration
 
-        Tethered Configuration
+            Tethered Configuration
 
         .. figure:: figures/image9.jpg
             :width: 451px
-            :height: 206px
             :align: center
             :alt: USB Connection to the Board
         
-        Mini USB Connection to the Board as seen from the bottom.
+            Mini USB Connection to the Board as seen from the bottom.
 
         For more details see: :ref:`beagleboneblack-connectivity`
 
-    .. group-tab:: Blue
+    .. tab-item:: Blue
 
         .. figure:: figures/blueconnect.jpg
             :width: 451px
             :align: center
             :alt: USB Connection to the Blue
 
-        Micro USB Connection to the Blue
+            Micro USB Connection to the Blue
 
-    .. group-tab:: AI-64
+    .. tab-item:: AI-64
 
         .. figure:: figures/usb-tethering.jpg
             :width: 400px
             :align: center 
             :alt: Tethered Configuration
 
-        Tethered Configuration  
+            Tethered Configuration  
 
         .. figure:: figures/usb-c-connection.jpg
             :width: 400px
             :align: center 
             :alt: USB Connection to the Board
 
-        USB-c Connection to the Board
+            USB-c Connection to the Board
             
         .. figure:: figures/usb-a-connection.jpg
             :width: 400px
             :align: center 
             :alt: USB Connection to the PC/Laptop
 
-        USB Connection to the PC/Laptop
+            USB Connection to the PC/Laptop
 
         .. figure:: figures/power-led.jpg
             :width: 400px
             :align: center 
             :alt: Board Power LED
 
-        Board Power LED
+            Board Power LED
 
-        For more details see: :ref:`connecting-up-your-beaglebone-ai-64`
+        For more details see: :ref:`bbai64-quick-start`
 
-    .. group-tab:: Play
+    .. tab-item:: Play
 
         .. figure:: figures/tethered-connection.jpg
             :width: 1400
             :align: center
             :alt: Tethering BeaglePlay to PC
 
-        Tethering BeaglePlay to PC
+            Tethering BeaglePlay to PC
 
         For more details see: :ref:`beagleplay-quick-start`
             
-    .. group-tab:: Pocket
+    .. tab-item:: Pocket
 
         .. figure:: figures/11fig-PB-microUSBattach1.jpg
             :align: center
             :alt: Tethered Configuration
 
-        Micro USB Connection
+            Micro USB Connection
 
         For more details see: :REF:`connecting_up_pocketbeagle`
             
@@ -112,81 +110,75 @@ heart beat.
 
 The Beagle is now up and running, but you didn't have to 
 load up Linux.  This is because all Beagles 
-have built-in flash memory 
+(except PocketBeagle, see :ref:`flash-latest-image` 
+to install an image on the Pocket) have built-in flash memory 
 that has the Debian distribution of Linux preinstalled.
 
-.. note:: 
-    The one exception is the PocketBeagle which has no built-in 
-    flash memory.  See :ref:`flash-latest-image` 
-    to install an image on the Pocket
-
-Login
------
-
-Next you login to the Beagle from your host computer. 
-Here you have a choice.  If you want a graphical approach, 
-choose the ``VS Code`` tab.  If you want a command line 
-and your host is a Mac, take the ``ssh (Mac)`` tab. If you
-are running Linux on your host, 
-take the ``ssh (Linux)`` tab.  Finally take the 
-``putty (Windows)`` tab for command line from Windows.
+.. _intro-using-vs-code:
 
-.. tabs::
+Using VS Code
+**************
 
-    .. group-tab:: VS Code
+.. important:: If VS code is not installed on your board please skip this section and refer 
+               to next section on how to login and run the code via command line.
 
-        Recent Beagles come with the IDE Visual Studio Code 
-        (https://code.visualstudio.com/) installed and 
-        running. To access it, open a web browser on 
-        your host computer and browse to: ``192.168.7.2:3000`` 
-        (use ``192.168.6.2:3000`` for the Mac)
-        and you will see something like:
+Recent Beagles come with the IDE Visual Studio Code (https://code.visualstudio.com/) installed and 
+running. To access it, open a web browser on your host computer and browse to: ``192.168.7.2:3000`` 
+(use ``192.168.6.2:3000`` for the Mac) and you will see something like:
 
-        .. figure::  figures/vscode1.png
+.. figure::  figures/vscode1.png
+    :width: 740 
+    :align: center
 
-        At this point you can either run the scripts via a command 
-        line within VS Code, or run them by clicking the
-        ``RUN Code`` button.
+At this point you can either run the scripts via a command line within VS Code, or 
+run them by clicking the ``RUN Code`` button.
 
 
-        Running via the command line
+Running via the command line
+============================
 
-            Open a terminal window in VS Code by dropping down the 
-            ``Terminal`` menu and selecting ``New Terminal`` (or entering 
-            ``Ctrl+Shift+```).  The terminal window appears at the 
-            bottom of the screen as shown below.
+Open a terminal window in VS Code by dropping down the ``Terminal`` menu and selecting ``New Terminal`` 
+(or entering ``Ctrl+```).  The terminal window appears at the bottom of the screen as shown below.
 
-            .. figure:: figures/vscode3.png
+.. figure:: figures/vscode3.png
+    :width: 740 
+    :align: center
 
-            You can now enter commands and see them run as shown below.
+You can now enter commands and see them run as shown below.
 
-            .. figure:: figures/vscode4.png
+.. figure:: figures/vscode4.png
+    :width: 740 
+    :align: center
+    
+Running via the ``RUN`` button
+===============================
 
-        Running via the ``RUN`` button
+Use the file navigator on the left to navigate to ``examples/BeagleBone/Black/blinkInternalLED.sh`` and you will see:
 
-            Use the file navigator on the left to navigate to 
-            ``examples/BeagleBone/Black/blinkInternalLED.sh`` 
-            and you will see:
+.. figure:: figures/vscode2.png
+    :width: 740 
+    :align: center
 
-            .. figure:: figures/vscode2.png
+This code blinks one of the USR LEDs built into the board. Click on the ``RUN Code`` triangle on the upper right of the 
+screen (see red arrow) to run the code.  (You could also enter ``Ctrl+Alt+N``) The USR3 LED should now be blinking.  
 
-            This code blinks one of the USR LEDs built into the board. 
-            Click on the ``RUN Code`` triangle on the upper right of 
-            the screen (see red arrow) to run the code.  (You could also enter ``Ctrl+Alt+N``) 
-            The USR3 LED should now be blinking.  
+Click on the ``Stop Code Run`` (``Ctrl+Alt+M``) square to the right of the ``Run Code`` button.
 
-            Click on the ``Stop Code Run`` (``Ctrl+Alt+M``) square to the right of the 
-            ``Run Code`` button.
+Time to play!  Try changing the LED number (on line 10) from 3 to something else.  Click the ``Run Code`` 
+button (no need to save the file, autosave is on by default).
 
-            
-            
-            Time to play!  Try changing the LED number (on line 10) from 
-            3 to something else.  Click the ``Run Code`` button (no 
-            need to save the file, autosave is on by default).
+Try running ``seqLEDs.py``.
 
-            Try running ``seqLEDs.py``.
+Using command line
+******************
 
-    .. group-tab:: ssh (Mac)
+To access the command line and your host is a Mac, take the ``ssh (Mac)`` tab. If you
+are running Linux on your host, take the ``ssh (Linux)`` tab.  Finally take the 
+``putty (Windows)`` tab for command line from Windows.
+
+.. tab-set::
+
+    .. tab-item:: ssh (Mac)
                 
         If you are running a Mac host, open a terminal widow and run 
 
@@ -196,7 +188,7 @@ take the ``ssh (Linux)`` tab.  Finally take the
 
         Use the password ``temppwd``.
   
-    .. group-tab:: ssh (Linux)
+    .. tab-item:: ssh (Linux)
 
         If you are running a Linux host, open a terminal widow and run 
 
@@ -206,7 +198,7 @@ take the ``ssh (Linux)`` tab.  Finally take the
         
         Use the password ``temppwd``.
 
-    .. group-tab:: putty (Windows)
+    .. tab-item:: putty (Windows)
 
         If you are running Window you need to run an ``ssh`` client 
         to connect to the Beagle. I suggest you use ``putty``. 
@@ -220,7 +212,7 @@ take the ``ssh (Linux)`` tab.  Finally take the
         and password ``temppwd``.  
 
 Blink an LED
-------------
+============
 
 Once logged in the rest is easy.  First:
 
@@ -241,7 +233,7 @@ internal LEDs.
 
 .. code-block:: shell-session
 
-    bone:~$ cat blinkInternalLED.sh
+    bone:~$ cat blinkInternalLED.py
     LED="3"
     
     LEDPATH='/sys/class/leds/beaglebone:green:usr'
@@ -252,25 +244,14 @@ internal LEDs.
         echo "0" > ${LEDPATH}${LED}/brightness
         sleep 0.5
     done
-    bone:~$ ./blinkInternalLED.sh
+    bone:~$ ./blinkInternalLED.py
     ^c
 
-:download:`blinkInternalLED.sh<code/blinkInternalLED.sh>`
-
 Here you see a simple bash script that turns an LED 
 on and off.  Enter Ctrl+c to stop the script.
 
-Congratulations, you've blinked an LED.
-
-Your turn
-^^^^^^^^^
-
-Now that you have an LED blinking, try blinking a different LED. 
-Or, blink more than one LED at a time. Try slowing down, or speeding up 
-the blink rate.
-
 Blinking via Python
--------------------
+====================
 
 Here's a script that sequences the LEDs on and off.
 
@@ -292,35 +273,19 @@ Here's a script that sequences the LEDs on and off.
     while True:
         for i in range(LEDs):
             f[i].seek(0)
-            f[i].write("1")     # 1 turns the LED on
+            f[i].write("1")
             time.sleep(0.25)
         for i in range(LEDs):
             f[i].seek(0)
-            f[i].write("0")     # 0 turns the LED off
+            f[i].write("0")
             time.sleep(0.25)
     bone:~$ ./seqLEDs.py       
     ^c
-
-:download:`seqLEDs.py<code/seqLEDs.py>`
-
+    
 Again, hit Ctrl+c to stop the script.
 
-This python script is a bit more complicated that the previous bash 
-script.  Note that *LEDPATH* is the same in both scripts.  They use the 
-same interface to control the built-in LEDs.  The python script opens a 
-file for each of the LEDs and then writes a **1** to the file to turn on 
-the LED.  A **0** is writen to turn it off.  The *for* loop allows it to turn 
-on (or off) all four LEDs in sequence.
-
-Your turn
-^^^^^^^^^
-
-Try speeding up, or slowing down the sequencing by changing the *sleep* times. 
-If you have programming experience, make a single LED sequence back and forth.
-
-
 Blinking from Command Line
---------------------------
+==========================
 
 You can control the LEDs from the command line.
 
@@ -343,18 +308,18 @@ You can blink any of them.  Let's try ``usr1``.
     bone:~$ echo 1 > brightness
     bone:~$ echo 0 > brightness
 
-When you echo **1** into ``brightness`` the LED turns on. 
-Echoing a **0** turns it off. 
+When you echo 1 into ``brightness`` the LED turns on. 
+Echoing a 0 turns it off. 
 
 Blinking other LEDs
--------------------
+===================
 
 You can blink the other LEDs by changing in to thier 
 directories and doing the same. Let's blink the USR0 LED.
 
 .. code-block:: shell-session
     
-    bone:~$ cd /sys/class/leds/beaglebone\:green\:usr0/
+    bone:~$ cd ../beaglebone\:green\:usr0/
     bone:~$ echo 1 > brightness
     bone:~$ echo 0 > brightness
 
@@ -378,20 +343,13 @@ what triggers you can set:
     bone:~$ echo none > trigger
 
 Notice ``[heartbeat]`` is in brackets.  This shows it's the 
-current trigger.  The ``echo`` changes the trigger to ``none``.
+current trigger.  The echo changes the trigger to ``none``.
 
-Your turn 
-^^^^^^^^^
 Try experimenting with some of the other triggers and see if you 
-can figure them out. Try changing the trigger on the other LEDs. 
-
-.. note:: 
-
-    The following may not work on all Beagles since it depends on which 
-    version of Debian you are running.
+can figure them out.
 
 Another way to Blink an LED
----------------------------
+===========================
 
 An interesting thing about Linux is there are often many ways 
 to do the same thing.  For example, I can think of at least five ways to blink 
@@ -426,26 +384,21 @@ the ``gpioset`` command.
 The first command sets chip 1, line 22 (the usr1 LED) to 1 (on) for 
 2 seconds.  The second command turns it off for 2 seconds.
 
-Your turn 
-^^^^^^^^^
-
-Try turning on and off the other LEDs. If you have programming experience, 
-try modifying the earler *bash* script to use `gpiod` instead of `echo`.
+Try it for the other LEDs.
 
 .. note:: 
 
-    The following may not work on all Beagles since it depends on which 
+    This may not work on all Beagles since it depends on which 
     version of Debian you are running.
 
-Blinking in response to a button event
---------------------------------------
+Blinking in response  to a button
+=================================
 
-Some Beagles have a **USR** button that can be used  to control the LEDs. 
-You can test the **USR** button with ``evtest`` 
+Some Beagles have a USR button that can be used  to control the LEDs. 
+You can test the USR button with ``evtest`` 
 
 .. code-block:: shell-session
 
-    bone:~$ sudo apt install evtest
     bone:~$ evtest
     No device specified, trying to scan all of /dev/input/event*
     Not running as root, no devices may be available.
@@ -457,7 +410,7 @@ You can test the **USR** button with ``evtest``
 We want to use ``gpio-keys``, so enter ``1``. Press and release 
 the USR button and you'll see:
 
- .. code-block:: shell-session
+.. code-block:: shell-session
 
     Input driver version is 1.0.1
     Input device ID: bus 0x19 vendor 0x1 product 0x1 version 0x100
@@ -486,41 +439,23 @@ the USR button and you'll see:
     Event: time 1692994988.641754, -------------- SYN_REPORT ------------
     Ctrl+c 
 
-The value **1** means the **USR** button was pressed, the **0** means it 
-was released.  The value **2** means the button is being held.
-
-The following script uses ``evtest`` to wait for the **USR** button to be 
-pressed and then turns on the LED.
+The following script uses evtest to wait for the USR button to be pressed and 
+then turns on the LED.
 
 .. literalinclude:: code/buttonEvent.sh
+    :language: Shell
     :caption: buttonEvent.sh
     :linenos:
 
-:download:`buttonEvent.sh<code/buttonEvent.sh>`
-
-Try running it and pressing the **USR** button. 
-
-.. code-block:: shell-session
-
-    bone:~$ ./buttonEvent.sh
-    ^c
-
-The **USR3** LED should turn on when the **USR** button is pressed.
-
-Your turn
-^^^^^^^^^
-Try modifying the code to turn on a different LED.  Try blinking 2 or 3 
-LEDs when the button is pressed.  Can you toggle an LED each time the 
-button is pressed?
+:download:`code/buttonEvent.sh<code/buttonEvent.sh>`
 
-Blinking in response to a button poll
--------------------------------------
+Try running it and pressing the USR button. 
 
-The next script polls the USR button and toggles the LED rather that waiting 
-for an event.
+The next script polls the USR button and toggles the LED.
 
 .. literalinclude:: code/buttonLED.sh
+    :language: shell
     :caption: buttonLED.sh
     :linenos:
 
-:download:`buttonLED.sh<code/buttonLED.sh>`
+:download:`code/buttonLED.sh<code/buttonLED.sh>`
-- 
GitLab