LED Controller
The LED Controller example application controls up to two 3W RGB LEDs. Using the LED Controller application, you can control each LED directly or via the IzoT network using the demo Web pages, as shown in the LED Control Web page. Â You can turn each LED on or off, dim each LED if it supports dimming, and set the color of each LED that supports color.
The LED Controller example application also supports up to two pressure sensors. Each corresponds to one of the two LEDs (sensor 1 to LED 1, sensor 2 to LED 2), and reads a pressure value from a hardware FSR sensor; when the detected pressure is over a given limit (configurable in the source code). Â The corresponding LED brightness is dimmed up/down continuously. To stop dimming, let go of the pressure sensor. The pressure sensor value is not shared over the IzoT network.
While running the LED Controller offers a connection target for the first LED on the LED Controller that Keypad devices can use to create keypad to LED connections.
In a typical demo setup, each LED will be controlled in both brightness and (if an RGB led) color by the keypad script (see Touch Keypad) over the network from the Web pages, and optionally in brightness only by the corresponding local pressure sensor.
This section consists of the following:
Hardware
The led.py script will work with the following hardware:
1x Raspberry Pi (Rev.2)
1x Adafruit 16-Channel 12-bit PWM/Servo Driver - I2C interface - PCA9685 (https://www.adafruit.com/products/815) Â to control the PMW LEDs (the Pi itself does not have enough PWM channels)
2x Star Controller - 3 Watt RGB Star LED Controller Kit with PWM input (https://solarbotics.com/product/60160/) to be used as main controlled LEDs
2x Round Force-Sensitive Resistor (FSR) - Interlink 402 (https://www.adafruit.com/products/166) to generate the pressure value that will be used to control the brightness of the LEDs
2x Simple PWM RGB LEDs (Adafruit 139) to be used as Connect lights
2x Pushbuttons to be used as Connect buttons
The schematics are available in Eagle and PDF format in the hardware directory within the LED Controller example directory.
Running the LED Controller Application
You can start the LED Controller example application as a service and optionally enable it to automatically run on boot, or you can run it from the command line. Running from the command line is useful for doing interactive testing and debugging. Running as a service is useful for setting up working networks and demonstrations.
To start the LED Controller example application as a service and enable it to run on boot, enter the following command:
izot_enable led
To stop the LED Controller example application and disable it from running on boot, enter the following command:
izot_disable led
To start the LED Controller example application without changing its boot status, enter the following command:
izot_start led
To stop the LED Controller example application without changing its boot status, enter the following command:
izot_stop led
To display the status of all IzoT services, enter the following command.
izot_stat
To run the LED Controller example application from the command line, change to the LED Controller example directory at $IZOT/izot/examples/led_controller and enter the following command at the Linux shell prompt:
supy led.py [-C] [-D] [-d DEVICE] [-h] [-I] [-i] [-L LED_TYPE] [-l LOG] [-m] [-N SCENES] [-n NVD] [-pPROGRAM_ID] [-s SENSOR] [-v] [-r RESET_TYPE]
The following table summarizes the command-line flags and options:
Flag / Option | Description |
---|---|
-C | Enables debugging with the PyCharm IDE. |
-D | Runs the LED Controller example application in debug mode. The log level is increased for both the console log and the application log. |
-d DEVICE | Sets the device URI, e.g. uc://10.0.1.12:1628. If not specified the default URI is used. |
-h | Displays the available flags and options. |
-I | Disables ISI. Without ISI, the application requires installation by a network management tool such as the IzoT Commissioning Tool. |
-i | Runs the LED Controller without any attached I/O hardware. This is useful for running the LED Controller on platforms that do not have the LED Controller I/O hardware. |
-L LED_TYPE | Specifies the LED type. LED_TYPE can be color or piface. If the value is color, six channels of a 16-channel PWM controller are used to control two color LEDs. If the value is piface, two digital outputs on a PiFace Digital I/O board are used. If not specified, the default LED type is color. |
-l LOG | Sets the path and filename for log files. If not specified, the default path is the LED Controller example directory, and the filename is LED. |
-m | Runs the LED Controller in demo mode. In demo mode, periodic ISI messaging is increased to speed up device and connection discovery. The result is that more bandwidth is consumed for ISI messaging provide faster discovery at the expense of less bandwidth for application data. |
-N SCENES | Specifies the number of scenes to be supported by the LED Controller. The SCENES value must be an integer value between 2 and 16, inclusive. If not specified, the default is 8 scenes. |
-n NVD | Specifies the path for the non-volatile data directory. If not specified the default directory is LED-nvd in the LED Controller example directory. |
-p PROGRAM_ID | Specifies a program ID for this running instance of the application. PROGRAM_ID is a 16-digit hex value described in the Defining the Program ID. If not specified the default program ID for the LED Controller example application is 9F:FF:FF:05:00:6F:00:02. Specify a different program ID if you have modified the IzoT interface for the example application and you need to load a different device class file for the modified application. |
-r RESET_TYPE | Clears persistent data. Set RESET_TYPE to 0 to clear all persistent data; set RESET_TYPE to 1 to clear all persistent data except for the device unique ID. RESET_TYPE 1 is useful to prevent a change in unique ID which will result in a new discovery of the device by the IzoT Server. |
-s SENSOR | Specifies the configuration of pressure sensors used for locally controlling the LED state. The following values of SENSOR are supported: none -- no pressure sensors are installed (default) single -- a single pressure sensor is installed to control both LEDs multi -- two pressure sensors are installed, one to control each LED |
-v | Runs the LED Controller example application in verbose mode. The log level is increased to the maximum level for both the console log and the application log. |