Turn Raspberry Pi LED On and Off
This example shows how to turn the on-board LED on and off.
Create a connection to the Raspberry Pi™ hardware usingraspi
.
mypi = raspi
mypi = raspi with properties: DeviceAddress: 'raspberrypi-computername' Port: 18725 BoardName: 'Raspberry Pi Model B Rev 2' AvailableLEDs: {'led0'} AvailableDigitalPins: [4 14 15 17 18 22 23 24 25 27 30 31] AvailableSPIChannels: {} AvailableI2CBuses: {'i2c-0' 'i2c-1'} I2CBusSpeed: 100000 Supported peripherals
TheAvailableLEDs
property shows the name of the user-controllable LED.
To show the location of the user-controllable LED on the board, useshowLEDs
.
showLEDs(mypi)
Turn the specified LED on by setting its value to1
ortrue
.
writeLED(mypi,'led0',1)
Turn the LED off by setting its value to0
orfalse
.
writeLED(mypi,'led0',false)
To restore the LED to its default purpose, which is to indicate SD card activity, restart the Raspberry Pi hardware.