Skip to content

Control LED switching using GPIO on BeagleBone Black (BBB)

pbsujit edited this page Jun 7, 2013 · 21 revisions

The LEDs on the BBB are on GPIOs 53,54,55,56 pin numbers. To access the GPIO pins, we will use the GPIO class in Dune. The definition of the GPIOs can be looked in DH>src/DUNE/Hardware/Dune.hpp. We will use the following steps to control LEDs.

  1. Create a new task, say GpioLed. How to create task is describe in Example 1.
  2. Include the header file
#include <DUNE/Hardware/GPIO.hpp>
  1. The GPIOs have two entities - (1) the direction, either input or output and (2) the value. We will first declare an entity of GPIO class in side the TASK struct as
struct Task: public DUNE::Tasks::Task
    {
      GPIO* m_out;
      //! Constructor.
      //! @param[in] name task name.
      //! @param[in] ctx context.
      Task(const std::string& name, Tasks::Context& ctx):
        DUNE::Tasks::Task(name, ctx),
	m_out(NULL)
      {
	bind<IMC::SetLedBrightness>(this);
      }

Clone this wiki locally