Dear MOD users!
Hi to all of you who want to use your Arduino Control Chain shield with an LCD screen.
We got the question on the forum some time ago, whether it would be possible to use LCDs on your Control Chain device and with the Control Chain library version 0.5.0 and up, it now is!
To help out, we thought that making an example of how to do this might come in handy. So let’s see!
WHAT DO I NEED?
- One Arduino Uno or Due
- One Arduino Control Chain shield
- Two 4×20 LCD Screens
- Four 10K linear potentiometers
- Some wire
- Some soldering tin
- Pin headers (recommended)
The schematic for this build looks a little more complicated than the previous ones, but most of the connections are used for the displays.
Note that in the schematic there are two 16×2 displays used. The code, however, is meant for two 20×4 displays. Nonetheless, the pin-out is the same in both cases.
To keep this blog post from being extremely long, here is a link to a more detailed description of the wiring of the LCD screen’s made by Adafruit.
Because we are connecting 2 displays instead of one, we can connect almost all pins from one display to the other. For the contrast pin, however, it is still recommended to use 2 different potentiometers. The reason for this is that the 2 displays are almost never the same. This way it is still possible to set the contrast individually.
The big difference between this schematic and the one from the Adafruit tutorial is the ‘enable’ line of the displays (pin 6). In the Adafruit tutorial, this pin is connected to Arduino pin 8. In our case, however, we connect the ‘enable’ pin of the first display to Arduino pin 5 and the ‘enable’ pin of the second display to Arduino pin 6. Also, 4 potentiometers are connected. By default, they are connected to A0, A1, A2, and A3. But this is easily changeable, if desired.
For ease of use, the LiquidCrystal library was used. This library makes writing to the LCDs a lot easier. There is, however, a downside to this approach. This library is rather slow and uses a lot of delays internally. Because of this, the example code will only work with the Control Chain library version 0.5.0 or up. As it is right now, this library is only compatible with the Arduino Uno. This is due to the UART interruption that by default cannot be used on the Arduino Due. A while ago a Pull request was opened to change this. If you really want to use an Arduino Due, scroll a little down on the Control Chain library Github page where you can find an explanation on how to do this.
The code is structured in such a way that it mostly depends on the Control Chain Callbacks. Whenever a value or assignment changes, the display will be updated as well. The values of the potentiometers are simply read by an analogRead() function.
- Wire up the LCD screens according to the schematic (either by soldering them directly or as recommended with the use of pin headers)
- Connect the potentiometers outer pins to +5V track and GND track of the CC shield
- Solder the potentiometers inner pin to the corresponding analog input of the CC shield (by default A0, A1, A2, A3)
UPLOADING THE CODE
Follow the instructions on our Github page and install the dependencies then upload the code to your Arduino.
All done, time to test! Connect the CC shield to your MOD DUO. If everything went well you should see a new CC device popping up:
Also, when powered on, the device should display a message like this:
The startup message
Then, assign the CC device to the actuator of your choice:
After assigning, the device should look like this:
All done! You should have yourself a working Hardware UI extender.
THE FINAL PRODUCT
You can also put your build in an enclosure. For me, that meant looking up old prototypes and again I reused one of the XF4 prototype enclosures.
Now, you have just finished your own Control Chain Hardware UI extender. Hopefully, this is helpful for all of you who wanted to see how to connect a display to the Arduino Control Shield. Don’t hesitate to come and talk to us on the forum if you have any questions about Control Chain devices, the Arduino or anything else!