Main Content

Turn BeagleBone Black LED On and Off

This example shows how to turn an onboard LED on and off.

  1. Create a connection to the BeagleBone® Black hardware and assign the connection to an object, bbb.

    bbb = beaglebone
    bbb = 
    
      beaglebone with properties:
    
               DeviceAddress: '192.168.7.2'
                   BoardName: 'BeagleBone Black Rev 00C0'
               AvailableLEDs: {'USR0'  'USR1'  'USR2'  'USR3'}
        AvailableDigitalPins: {1x29 cell}
         AvailableAnalogPins: {'AIN0'  'AIN1'  'AIN2'  'AIN3'  'AIN4'  'AIN5'  'AIN6'}
            AvailablePWMPins: {}
        AvailableSPIChannels: {}
           AvailableI2CBuses: {'i2c-1'}
        AvailableSerialPorts: {}
            AvailableWebcams: {} 
  2. The AvailableLEDs property shows the name of the user-controllable LED. To show the location of the user-controllable LED on the board, type:

    showLEDs(bbb)

    The figure shows the output of a call to showLEDs.

  3. Turn the specified LED on by setting its value to 1 or true.

    writeLED(bbb,'usr0',1)
  4. Turn the LED off by setting its value to 0 or false.

    writeLED(bbb,'usr0',false)
    

To restore LED 'usr0' to its default, which is to indicate Linux® kernel activity, restart the BeagleBone Black hardware.