Home Guides Example Code 101: The Basics & Benefits

Example Code 101: The Basics & Benefits

by Newhaven Staff
Published: Last Updated on 863 views

Coding, programming, and example code are essential parts of nearly every electronic device. The information in this article is relevant to many different applications, but our examples will focus specifically on display applications like TFT LCDs and OLED displays. Even if you’re not working with display devices, you’ll still be able to apply the information here to your own projects!

Introduction: Microcontrollers & Code

No matter what kind of display you are working with, it’s going to need a microcontroller to tell it what to do.  For example, LCD and OLED displays rely on programmed microcontrollers to tell them what pixel graphics to show on the screen. All microcontrollers are programed by the user with code. The code is unique to the user based on the microcontroller they are using. Writing code can be difficult when the user is not familiar with the display IC or their own microcontroller. That’s why we developed an online library of code to help you get started with our displays. In this post, we break down what example code consists of and how it can be such a helpful resource.

What is example code?

Example code helps users to quickly get their new applications up and running in the shortest time possible. The engineers who design the product will write this code and make it freely available to end-users. The goal is to give users a solid foundation to begin developing.

What can example code do?

Like the name implies, example code is meant to serve as an example that shows certain capabilities of the display. Simply put, there are no limits to how complex or basic the code can be. Typically, the example code will just provide the minimum amount of information needed for the display to power on, but it’s capable of doing much more. We recommend using our various example code to see the different capabilities of our displays. Exploring these options can often lead to new ideas on how to drive the display with your application.

Despite being such a helpful resource, example code won’t just start working right away. The display needs to be connected with a microcontroller first. You also might need to modify the code depending on the microcontroller you are using. The code we provide always includes a display initialization section.

Image of two monochrome graphic OLED displays showing different graphics.
This OLED display is using example code to demonstrate its monochrome graphic capabilities.

Initialization Code

Initialization code (commonly referred to as “init” code) is the most basic part of code you’ll come across. It’s the most important part of the example code because it gets the display ready to receive information. Once implemented, the initialization code opens the door for other code to start showing pixels.

Many manufacturers give customers initialization code for their products. This helps users get a head start in programming for the development of the product. For applications with multiple capabilities, the user will sometimes need to add more functions in the code to showcase the capabilities of their product.

How can example code help?

Beyond the immediate benefit of simply getting your new display working in the shortest time possible, how else does example code help? And how can it improve your coding skills overall?

For starters, example code teaches you the “how” behind a device’s programming. In addition to seeing the code take effect in your application, you also get access to the specific lines of code that that are making it happen. Being able to study the code that’s already provided makes it easier for first-time users to understand how a specific display works.

Furthermore, example code can act as everything from an initialization quick start to a guide on understanding difficult communication protocol. It can even become a springboard for developing new concepts and ideas of your own. Example code is often freely available to anyone who wants to use it. This makes it a valuable resource for anyone looking to program more and improve their skills.

When you analyze how code functions, you pick up new techniques to improve your own writing and coding process. A smart, elegant line of code that you come across in an example can be applied to your own code and improve your processes in future projects. 

Conclusion

Now that you know the fundamentals, you can start using the examples you find on our website to their fullest potential. Remember to stay on the lookout for helpful examples and stay open to new ideas. The more you read code written by others, the more your own programming skills will improve.

What We Have to Offer

Image of person coding with text "We've got you covered! Free example code"

Digital display developers, we’ve got you covered. Our engineers assembled a wealth of information to help you develop for LCD, TFT, and OLED display applications. Our engineering resources also include code for Arduino and BeagleBone.

Take a look at the code provided on our Example Code page. 

Example Videos

See our code in action on LCD and OLED displays.  All the code in the example videos is available for download. See the video descriptions on YouTube for individual links or view all available code on GitHub.

You may also like

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.