Skip to content

ViSi-Genie Magic: Arduino 32bit LED Digits


Signed number operation with 16-bit integers limits the maximum number that can be displayed by LED digits objects to "32,767". 2^16 equals 65,536. Divide this by two since the first half is used to represent positive numbers; the remaining half is used to represent negative numbers. Thus, attempting to create a 6-digit LED digits object or to send to a LED digits object a value beyond the limit results to red "X" marks on the object during runtime. To be able to display a value higher than "32,767" in ViSi-Genie, one solution is to create two adjacent four-digit LED digits objects and write a routine in the host program for driving these two objects. This routine shall determine the correct values to be written to the two LED digits objects, given any value higher or lower than "32,767".

With the release of Workshop4 PRO, it is now possible for users to insert 4DGL codes into Genie projects. This feature, which can be collectively called as "Genie Magic", allows for more flexibility in the user's project, compared to those created in the standard Genie environment. One object under the Genie Magic pane is the magic object. This is actually a 4DGL function which allows users to handle bytes received from an external host. The user, for example, can create a magic object that waits for 4 bytes (which can represent 32-bit integers) and writes the decimal equivalent value to a collection of LED digits objects. Thus, the host does not need to worry about handling the LED digits objects, it just writes to the magic object. The ViSi-Genie-Arduino library has been updated to include a function for writing to a magic object. This code presents a working example of the above.


Worskhop 4 PRO is needed for this codebase example.


This codebase example assumes the reader can program the 4D Systems display module using Workshop4 IDE ViSi-Genie environment. Beginners are advised to read the following aplication notes.


Below are the steps involved in creating this code example.

  1. Create an Arduino sketch for sending 32-bit (4 bytes) integers to the display. To represent all possible values of a 32-bit number in decimal, 10 digits are required - 2^32 = 4,294,967,296. Compile the sketch and upload the program to an Arduino Uno.

  2. In Workshop4 create a new ViSi-Genie project and add three LED digits objects.

    • Leddigits0 - 4 digits, will display the first four least significant decimal numbers (ZZZZ as shown below)
    • Leddigits1 - 4 digits, will display the second four least significant decimal numbers(YYYY as shown below)
    • Leddigits2 - 2 digits, will display the two most significant decimal numbers (XX as shown below)

    • XXYYYYZZZZ -> LED digits objects designation

    • 4294967296 -> decimal number example

    The LED digits objects are positioned on the WYSIWYG screen accordingly.


    It is possible to display the 10 digits using a single LED digits object. Another version of this code example using a single LED digits object will be posted

  3. Add a magic object to the ViSi-Genie project. Write the routine for computing the first-four and second-four least significant and the two most significant decimal values. The values are then written to the appropriate LED digits objects. This routine is MagicObject0.

  4. Another magic object, MagicObject1, is created. This is very similar to MagicObject0, except that it interprets and displays the received 4 bytes as a SIGNED long decimal number. MagicObject0 interprets and displays the received 4 bytes as an UNSIGNED long decimal number.

  5. Compile the project and upload it to uLCD-32PTU or any of our display with PICASO, DIABLO-16, PIXXI-28 and PIXXI-44 graphics processors. Copy the supporting files to a uSD mounted to the PC. Properly unmount the uSD card from the PC and mount it to your target display.

  6. Properly connect the Arduino Uno to the uLCD-32PTU or on your target display.

If without an Arduino host, you can still run this code example by performing steps 2, 3, 4, and 5. Then use the GTX tool to send 4 bytes at a time to the display.


Project File