Difference between revisions of "Arduino LiquidCrystal tutorial"

From MOD Wiki
Jump to navigation Jump to search
(creating page)
 
m
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
[[Category:Arduino Shield Tutorials]]
 +
 
This tutorial answers a question posted to the forum asking 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!
 
This tutorial answers a question posted to the forum asking 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!
  
Line 14: Line 16:
 
== SCHEMATIC ==
 
== SCHEMATIC ==
  
+
[[File:LCD-1.png]]
  
 
The schematic for this build looks a little complicated, but most of the connections are used for the displays.
 
The schematic for this build looks a little complicated, but most of the connections are used for the displays.
Line 34: Line 36:
 
== THE BUILD ==
 
== THE BUILD ==
  
    Wire up the LCD screens according to the schematic (either by soldering them directly or as recommended with the use of pin headers)
+
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)
+
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)
  
 
   
 
   
Line 45: Line 49:
 
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:
 
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:
  
 +
[[File:LCD-2.png]]
 
   
 
   
 
Control Chain device on MOD GUI Success!
 
Control Chain device on MOD GUI Success!
 
 
  
 
Also, when powered on, the device should display a message like this:
 
Also, when powered on, the device should display a message like this:
  
+
[[File:LCD-3.png]]
control chain device mod duo lcd screen The startup message
 
 
 
 
 
 
The startup message
 
  
 
Then, assign the CC device to the actuator of your choice:
 
Then, assign the CC device to the actuator of your choice:
  
+
[[File:LCD-4.png]]
Control Chain device on MOD GUI Address it like any actuator on the GUI
 
  
+
Address it like any actuator on the GUI
  
 
After assigning, the device should look like this:
 
After assigning, the device should look like this:
  
+
[[File:LCD-5.png]]
lcd screen control chain accessory mod duo The screens show the assigned parameters
 
  
+
The screens show the assigned parameters
  
 
All done! You should have yourself a working Hardware UI extender.
 
All done! You should have yourself a working Hardware UI extender.
Line 79: Line 75:
 
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.
 
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.
  
+
[[File:LCD-6.png]]
transparent enclosure control chain device mod duo lcd screen The 4 extra potentiometers controller with the 2 LCD screens looking good!
+
 
 +
The 4 extra potentiometers controller with the 2 LCD screens looking good!
 +
 
 +
Note: This tutorial was originally published by Jesse Verhage at the [https://www.moddevices.com/blog/2018/01/15/tutorial-liquidcrystal-and-control-chain Mod Devices blog]

Latest revision as of 23:28, 10 November 2018


This tutorial answers a question posted to the forum asking 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!

WHAT DO I NEED?

  1. One Arduino Uno or Due
  2. One Arduino Control Chain shield
  3. Two 4x20 LCD Screens
  4. Four 10K linear potentiometers
  5. Some wire
  6. Some soldering tin
  7. Pin headers (recommended)


SCHEMATIC

LCD-1.png

The schematic for this build looks a little complicated, but most of the connections are used for the displays.

Note that in the schematic there are two 16x2 displays used. The code, however, is meant for two 20x4 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.

THE CODE

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.

THE BUILD

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:

LCD-2.png

Control Chain device on MOD GUI Success!

Also, when powered on, the device should display a message like this:

LCD-3.png

Then, assign the CC device to the actuator of your choice:

LCD-4.png

Address it like any actuator on the GUI

After assigning, the device should look like this:

LCD-5.png

The screens show the assigned parameters

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.

LCD-6.png

The 4 extra potentiometers controller with the 2 LCD screens looking good!

Note: This tutorial was originally published by Jesse Verhage at the Mod Devices blog