#include // register the LiquidCrystal control and data pins // for the dfrobots LCD shield. LiquidCrystal LCD(8,9,4,5,6,7) ; static FILE lcdout = {0} ; // LCD FILE structure // LCD character writer static int lcd_putchar(char ch, FILE* stream) { LCD.write(ch) ; return (0) ; } void setup(void) { // LCD shield is 16 columns by 2 rows LCD.begin(16,2) ; // fill in the LCD FILE structure fdev_setup_stream (&lcdout, lcd_putchar, NULL, _FDEV_SETUP_WRITE); } void loop(void) { float seconds ; // calculate seconds as a floating point value seconds = (float) millis() /1000.0 ; // set the LCD cursor position to home LCD.setCursor(0,0) ; // report seconds since starting // in the X.xxx floating point format. fprintf(&lcdout, "Alive %.3f sec", seconds ) ; // wait 1000 milliseconds delay(1000) ; }