Lab 2
Lab 2
In this Lab we will step through creating a simple counter, and displaying that value
on an LCD display.
In this Lab you will be introduced to a new flowchart command; the component
macro.A component macro is how we interface with the more complex components
in Flowcode.
For simple things like switches and LEDs we can use inputs and outputs.
However, if we want to talk to an LCD screen we may need to execute a series of
commands back and forth.
Create a new flowchart with the correct microcontroller selected and add an LCD
(Generic, 20 x 4) screen to the 2D simulation panel.
With the LCD screen added to the simulation panel you should check its;
We will now quickly progress through a few steps where we are doing familiar
coding.
Counter = Counter + 1
The Start routine is required to initialize the LCD screen, so that the microcontroller
knows it exists, and sets up timing routines etc.
With the screen initialized we need two more component macros.
The first is to display the value of the variable ‘counter’ on the LCD screen.
Add another component macro within the while(1) loop, directly above the calculation
box.
Configure it to be a ‘PrintNumber’ macro, however, you will notice that there is a
parameter box that you must now fill in, called ‘Number’.
Here we must write the name of our variable; Counter.
Each time this command is now executed it will display whatever value we currently
have saved in counter.
There is one final component macro we need. We want our value of Counter to
always be displayed in the top left corner (X,Y position; 0,0).
Currently our program will write the value of Counter on the LCD screen, however,
the cursor will move each time we write a value and we will end up with something
like below;
What we need to do is clear the LCD screen each time we write a new value.
Luckily for us executing a clear screen routine also moves the cursor position back to
(0,0). Add another component macro above the PrintNumber macro, and configure it
to ‘Clear’.
We have now finished third lab.
You should first test your program is right by comparing it to the code listing below.
Simulate, before downloading to hardware to check it's worked as expected.
Did you know?
The BL0114 combo board has small slide switches used to turn
the LCD screen and the 7SEG LCD screen on and off.
Make sure that this switch in in the ‘on’ position for the LCD
screen when using the display.