Home Code Nucleo F334R8 LCD example

Nucleo F334R8 LCD example

by shedboy71

In this example we will add an Arduino LCD keypad shield to a ST Nucleo F334R8. This is a 16×2 LCD Keypad module for Arduino Diecimila Duemilanove, UNO, MEGA1280, MEGA2.

It consists of a 1602 white character blue backlight LCD. The keypad consists of 5 keys — select, up, right, down and left. To save the digital IO pins, the keypad interface uses only one ADC channel. The key value is read through a 5 stage voltage divider.

Here are the pins and their functions

Pin Function
Analog 0 Button (select, up, right, down and left)
Digital 4 DB4
Digital 5 DB5
Digital 6 DB6
Digital 7 DB7
Digital 8 RS (Data or Signal Display Selection)
Digital 9 Enable
Digital 10 Backlit Control

Here is a picture of this shield

lcd keypad shield

lcd keypad shield

Code

The code is for the mBed online compiler at https://developer.mbed.org/ and uses the freetronics LCD library

[codesyntax lang=”cpp”]

#include "mbed.h"
#include "freetronicsLCDShield.h"
 
freetronicsLCDShield lcd(D8, D9, D4, D5, D6, D7, D1, A0);

 
int main() 
{
    lcd.cls();
    // print the first line and wait 3 sec
    lcd.printf("LCD test");
    wait(3);
    
    // print the counter prefix; the number will be printed in the while loop
    lcd.setCursorPosition(1, 0);
    lcd.printf("seconds : ");
    
    int i=1;
    while (i++) 
    {
        lcd.setCursorPosition(1, 11);
        lcd.printf("%d", i);
        wait(1);
    }
}

[/codesyntax]

Share

You may also like