#include <LiquidCrystal.h> //Load Liquid Crystal Library
LiquidCrystal LCD(10, 9, 5, 4, 3, 2); //Create Liquid Crystal Object called LCD
int myCounter=0; //declare your variable myCounter and set to 0
void setup() {
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
digitalWrite(6, LOW);
digitalWrite(7, HIGH);
LCD.begin(16,2); //Tell Arduino to start your 16 column 2 row LCD
LCD.setCursor(0,0); //Set LCD cursor to upper left corner, column 0, row 0
LCD.print("My Timer:"); //Print Message on First Row
}
void loop() {
write_to_LCD(76.45);
delay(2000);
}
void write_to_LCD(float spd){
LiquidCrystal LCD(10, 9, 5, 4, 3, 2);
const byte smile[8] = {
B00000,
B00000,
B01010,
B00000,
B10001,
B01110,
B00000,
B00000
};
const byte frown[8] = {
B01010,
B00100,
B10001,
B00000,
B00000,
B01110,
B10001,
B00000
};
LCD.createChar(0, smile);
LCD.createChar(1, frown);
LCD.begin(16, 2);
LCD.setCursor(0, 0);
LCD.print("Measured Speed:");
LCD.setCursor(0, 1);
LCD.print(spd);
LCD.print(" km/h");
LCD.setCursor(15, 1);
spd <= 70 ? LCD.write(byte(0)) : LCD.write(byte(1));
}