Home mbedmbed Examples ST Nucleo F334R8 LCD example

ST Nucleo F334R8 LCD example

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

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]

You may also like