This example demonstrates how to control elements of a MegunoLink Interface Panel remotely. In this case, color is measured with a TCS34725 Red-Green-Blue (RGB) color sensor by an Arduino. The Arduino calculates the perceptual color and shows it on a MegunoLink interface panel.

Arduino-Driven Interface

MegunoLink Interface Panels are a handy way to control an Arduino program using buttons, sliders, textboxes, and other familiar GUI elements. However, Interface Panels can do more than send commands. Interface Panels can themselves be controlled by an Arduino program.

Driving the controls of an Interface Panel from an Arduino program allows for more advanced user feedback than LEDs or lines on a serial monitor. Many key properties of common controls such as progress bars, check boxes, numeric up/downs, text boxes, value lists, and more can be set at will. Simply use the InterfacePanel class in the MegunoLink Arduino library to send commands to an MLP UI Message Processor in an Interface Panel. It’s a lot faster to get up and running than developing a custom application, and allows all the logic for application and interface to be in one program. See the article on How to Update Interface Panel Controls from your Arduino for more details.

MegunoLink Interface Panel displaying colour mensurements visually and numerically.

Controlling a MegunoLink Interface Panel over serial is a quick way to develop a responsive GUI for any Arduino Project.

This example takes colour measurements and displays them to the user. The measurements are represented in two ways, visually using a colour-changing square panel and numerically by three numeric up/down controls. The colour of the square panel and the values of the numeric controls are set by the Arduino program over serial every time a new colour measurement is made.

Additionally, UDP could be used instead of serial to allow a connection over a WiFi/Ethernet network. This is especially handy for controlling and receiving measurements from remote sensors.

Gamma Correction

One complication to displaying the colour measurements visually is gamma correction. In short, the sensor outputs measurements on a linear scale, but computer monitors output colour according to a nonlinear gamma scale. Gamma encoding is the process of converting linear colour intensity values to the gamma = 2.2 ‘power’ scale values that computer monitors expect. The onscreen colour measurement recreation wouldn’t look true-to-life without being gamma encoded first. More details in this article on gamma correction and in the gamma correction Wikipedia page.

Downloads

You can download a ZIP file containing the Arduino program and matching MegunoLink interface from this example below. This example also requires our Arduino Library.

RGBSensorDisplay
RGBSensorDisplay
RGBSensorDisplay.zip
Version: 1
4 KiB
49 Downloads
Details

Example Code

Recent Posts

Leave a Comment

Start typing and press Enter to search