Hello World with a LCD

Overview

We are super excited to have our devices in your hands now. We got a request to show a Hello World example with the LCD Display from the Starter Kit, so here we go. This project allows you to turn a LCD showing “Hello World“ on and off with the push of a button.

beginner

10 Minutes

2 Clients


Hardware Components

Picture

Name

Quantity

Link

Picture

Name

Quantity

Link

Tactile Push Button

1

Included in Component Kit

Or you can purchase it here

Jumper Cables

(2x MM+ 4x MF)

6

Included in Component Kit

Or you can purchase it here

Breadboard(any size)

1

Included in Component Kit

Or you can purchase it here

I2C LCD

1

Included in Component Kit

Or you can purchase it here

Q-Client Builder Base

2

Q-Client

Tools Used

Picture

Name

Quantity

Link

Picture

Name

Quantity

Link

Small slotted-head screwdriver

1

Included in the Component Kit

or you can pick from one on our Recommended Tools List


Assemble the Circuit

Grab the client you want to use for the LCD, 4 male to female jumper cables and the 2x16 LCD.
Connect the GND of the client to the GND of the LCD, the 5V to the VCC of the LCD and the SDA and SCL to the corresponding ports on both the client and LCD.

Next get the other client, 2 male to male jumper cables, the tactile push button and the breadboard.
Place your button on the bread board and attach two wires to either set of pins that are diagonal from each other. Taking the leads that are connected to the button, connect one to GP0 and the other to 3.3V on the Builder Base.


Pair the Builder Base

Now we want to pair the Builder Base with our Q-Server. In order to do so, go to the Homescreen of your Q-Server.

Next click on the lift side symbol labeled “Clients”. Switch to the “Unpaired” tab at the top middle of the screen.

You should see your unpaired Builder Base. If not, check if you have plugged in the power supply for the Builder Base. Now move to the three dots below “Actions” and click “Pair”.

Once your Client is paired, click the “Setup” button.

Now you can edit your Client. Give him a Name you want and also a location where you are going to use it. Hit “Save” when you finished.


Build the Firmware

We will build two sets of firmware files: one for the button and one for the LCD.
If you already built the basic Hello World Project 1 you can reuse the button firmware.

Click the “+Create New” button. Name your new file “Hello World - Button” and hit “Create”.
Next, select “+ Add Hardware”. Using the search functions find the “Button” hardware and name it “Button”.

To configure the button, select the GPIO driver from the driver dropdown menu.
Set the Pin to GP0, Debounce to Enabled, and Pin Mode to Input Pull Down.
Save your firmware file.

Next we will create the firmware for the LCD. The procedure here is slightly different, since the LCD operates via I2S, so we need to know the address on the I2S bus.
Navigate to the Client view, find the LCD client, press the action button and select “Debug”. Press the I2C “Scan” button, so the client can scan for devices on the I2C bus. You should see a notification “Found address: XX”. Write this number down because we will need this for the LCD firmware generation.

Navigate back to the Firmware view and create a new firmware with the name “Hello World - LCD”. Next, select “+ Add Hardware”. Using the search functions find the “LCD” hardware and name it “LCD”.

Configure the LCD driver, select the Generic LCD2004 Driver 1. Put the I2C address of the LCD in the I2C Address field. For layout select 2x16 and save your firmware.

Now go ahead and upload the firmware files to the corresponding clients.


Build the App

You are almost done. Writing the app is the last big step.
Navigate to the Apps page and click “+ Create New”.
Name your app “Hello World LCD” and click create.

Use the search bar on the left hand side and search for “Button”. Drag both the “Hardware” and “Interface” Button objects onto the canvas. Next search for “Input Text” and drag the “Input Text” object onto the canvas. We will use the buttons to trigger an update of the LCD screen and the input text to modify the text displayed on the LCD.

Go ahead and name the Objects according to your taste by selecting a object and editing the object name in the inspector on the right.
Next add a “Data Sequence” and a “Static String” object. The data sequence will help us performing actions in a sequential way, while the static string will contain the text, that will be sent to the LCD. Select the incoming “String” port of the static string object and setting the “Default Value” to “Hello World”. Click “Save Properties” on the bottom of the inspection panel.

As the last object drag the LCD hardware object onto the canvas.
Your canvas should look like this:

Since we have all the required objects on our canvas now we can start adding links between the objects. First add a between the “State” ports of the buttons and the “Trigger” port of the data sequence, so the sequence will be triggered once you press a button on the dashboard or you press the physical button. Next add a link between the “Text” port of the input text and the “String” port of the static string object. This will ensure we save the text from the input text and send it to the LCD once a button is pressed. Lastly we need to connect the LCD to our logic.
To update the LCD once a button is pressed connect the “Trigger 1” of the data sequence port with the “Clear” port of the LCD, the “Trigger 2” port with the “Trigger” port of the static string and the “Trigger 3” Port with the “Send to Display” port. As the last step, connect the outgoing “String” port of the static string with the “String” port of the LCD.

Tip: Add anchors for links by holding the “ALT” key while dragging a selected link.

Save the app.


Map the Hardware

Go back to the Apps page and hit the play button of the Hello World LCD app.
The interface will now ask you to assign physical hardware to the hardware objects inside the app.
Assign the LCD on the LCD client to the LCD object and the button connected to the button client to the button hardware object.

Once you have 2 green checkmarks you are ready to go. Hit “Save + Run”.


Run the App!

Go ahead and test the app now by opening up the Dashboard and selecting the “Hello World LCD” App.

Go ahead and press the button on the interface. The LCD should now show “Hello World”. The same thing happens if you use the hardware button.

If you want to change the text start typing the the input text element on screen and hit either the physical button or the software button to trigger an update on the LCD.

YOU MADE IT. CONGRATULATIONS!

We are excited about the projects you come up with.

HAPPY MAKING!


Resources

Application

 

Application

 

Firmware