could some one help me to program for lcd

im new to all this and have finaly got my diy crono to work but i want it so the info comes up on the lcd could any one guied me on how to do this

Google up some LCD screens. Look at the tutorials for them. Look at the specs for conflicts between that screen and the hardware you are already using.

If you want help selecting a screen, you will need to share details about your project so far.

Edit, I saw in your older posts that you had copied code from a site. Can you give us a link to that site?

The sight I got it from is in Russian and he didn't use a screen he used it on a laptop but I want to make it portable I have a 16x2 lcd keypad shield I can post up the program if thats any help

here is my code it is a differnt one to what i was using befor

char masschar [5]; // array to translate characters
String massstring; // string, which specifies the mass in the mass selection mode
int set, setmass, rapidtime;
boolean initial,flagmass,flagmassset,rapidflag; // flags
int n=1; // shot number, starting at 1
float velocity,energy; // variable to store the speed
float mass=0.00020; // shell weight in kilograms
float dist=0.0635; // distance in meters between sensors  
volatile unsigned long gap1,gap2; // timestamps bullet passage sensors
unsigned long lastshot;

void setup () {
  Serial.begin(9600); // open the COM port
  attachInterrupt(1,start,RISING); // hardware interrupt when passing the first sensor
  attachInterrupt(0,finish,RISING); // Hardware interrupt the passage of the second sensor
void start() 
  if (gap1==0) {// if the measurement has not yet been carried out
    gap1=micros(); // get the time of Arduino from power on until the first bullet proletaniya
void finish() 
  if (gap2==0) {// if the measurement has not yet been carried out
    gap2=micros (); // get the time of Arduino from power on until a second bullet proletaniya
void loop() {
  if (initial==0) {// check the first run
    Serial.println("3 to rapidity"); // rate of measurement mode
    Serial.println("2 to mass set"); // select the projectile weight mode
    Serial.println("1 to service"); // debug mode (resistors)
    Serial.println("0 speed measure"); // exit the
    Serial.println("System is ready"); // notice that cron ready to go
    Serial.println(" ");
    initial=1; // first run, no longer show posts

  if (Serial.available() > 0 && set!=2) {// Thou have any letters on the entrance to the port and 2 mode is selected
    int; // read what was sent to the port
    switch(val) {// operator selection

    case 48: set=0; flagmass=0; rapidflag=0; initial=0; break; // If 0 is taken to select mode 0
    case 49: set=1; break; // if 1 took the run mode 1
    case 50: set=2; break; // if the run took 2 Mode 2
    case 51: set=3; break; // if the run took 3 Mode 3

  if (set==1) {// if mode 1
    Serial.print("sensor 1: ");
    Serial.println(digitalRead(2)); // show the value of the first sensor
    Serial.print("sensor 2: "); 
    Serial.print(digitalRead(3)); // show the value of the second sensor
    Serial.println(); // well Tipo two newline

  if (set==2) {// if mode 2
    if (flagmass==0) {// check box to show the label only 1 time
      Serial.print("Set the mass of bullet (gramm): "); //inscription
    if (Serial.available() > 0) // if there is an input from the port
      massstring = Serial.readStringUntil('\n'); // assign massstring all that have been sent to the port
      flagmassset=1; // raise the flag
    if (flagmassset==1) {// if the flag is raised (brought value to the port)
      Serial.println(massstring); // write the entered value
      Serial.println(" ");
      massstring.toCharArray(masschar,sizeof(masschar)); // translation values ​​in float (decimal)
      mass=atof(masschar)/1000; // still translation
      flagmass=0; // delete all the boxes    
      set=0; // show welcome sign

  if (gap1!=0 && gap2!=0 && gap2>gap1 && set==0) {// if the bullet had passed both sensors in 0 mode
    velocity=(1000000*(dist)/(gap2-gap1)); // calculation speed as distance / time
    energy=velocity*velocity*mass/2; // calculation of energy
    Serial.println(n); // Display the shot number
    Serial.print("Speed: ");    
    Serial.println(velocity); // print speed in COM
    Serial.print("Energy: ");    
    Serial.println(energy); // the output energy COM
    Serial.println(" "); 
    gap1=0; // reset values
    n++; // shot number +1

  if (micros()-gap1>1000000 && gap1!=0 && set!=1) {// (if the bullet has passed the first sensor) and (already passed 1 second, and the second sensor is not touched)
    Serial.println("FAIL"); // gives FAIL 1 second, when the bullet passed through the first sensor, and a second to none

  if (set==3) {// rate of mode
    if (rapidflag==0) {
      Serial.println("Welcome to the rapidity test!");
      rapidflag=1; // show the label once
    if (gap1!=0) {// if passed through the first sensor
      rapidtime=60/((float)(gap1-lastshot)/1000000); // calculation of the rate of rds / min
      lastshot=gap1; // Remember the time between shots
      Serial.print("Rapidity (shot/min):"); //conclusion
      Serial.println(" ");
  delay(200); // delay for stability

it will involve alout of changing in the code, do you just have a plain 16x2LCD or are u using a piggyback/ backpack. the code for the two is slightly diffrent.

when you program the code to run on the lcd you will have to add things like this ’
lcd.print(“3 to rapidity”);
lcd.print(“2 to mass set”);
for (int positionCounter = 0; positionCounter < 13; positionCounter++) {
lcd.print(“1 to service”);
lcd.print(“0 speed measure”);
lcd.print(“System is ready”);
lcd.println(" ");

thats just an example.
you will have to program a menu function to sellect the options and it must be capable of scrolling aswel also the 16x2 is a bit small if you could i would recomend a lcd with 4 lines instead of 2.
here is a menu code that works very well with lcd, i have used it in many of my aplications.

 // include libs
  #include <LCDMenuLib.h>
  // lib config
  #define _LCDML_DISP_cfg_button_press_time          200    // button press time in ms

// ********************************************************************* 
// *********************************************************************
  // settings for lcd 
  #define _LCDML_DISP_cols             20
  #define _LCDML_DISP_rows             4  

// *********************************************************************
// *********************************************************************
  // create menu
  // menu element count - last element id
  // this value must be the same as the last menu element
  #define _LCDML_DISP_cnt    11
  // LCDML_root        => layer 0 
  // LCDML_root_X      => layer 1 
  // LCDML_root_X_X    => layer 2 
  // LCDML_root_X_X_X  => layer 3 
  // LCDML_root_... 	 => layer ... 
  // LCDMenuLib_add(id, group, prev_layer_element, new_element_num, lang_char_array, callback_function)
  LCDML_DISP_add      (0  , _LCDML_G1  , LCDML_root        , 1  , "Information"        , LCDML_FUNC_information);
  LCDML_DISP_add      (1  , _LCDML_G1  , LCDML_root        , 2  , "Time info"          , LCDML_FUNC_timer_info);
  LCDML_DISP_add      (2  , _LCDML_G1  , LCDML_root        , 3  , "Settings"           , LCDML_FUNC);
  LCDML_DISP_add      (3  , _LCDML_G1  , LCDML_root_3      , 1  , "Change value"       , LCDML_FUNC);
  LCDML_DISP_add      (4  , _LCDML_G1  , LCDML_root_3      , 2  , "Something"          , LCDML_FUNC);
  LCDML_DISP_add      (5  , _LCDML_G1  , LCDML_root        , 4  , "Program"            , LCDML_FUNC);
  LCDML_DISP_add      (6  , _LCDML_G1  , LCDML_root_4      , 1  , "Program 1"          , LCDML_FUNC);
  LCDML_DISP_add      (7  , _LCDML_G1  , LCDML_root_4_1    , 1  , "P1 start"           , LCDML_FUNC);
  LCDML_DISP_add      (8  , _LCDML_G1  , LCDML_root_4_1    , 2  , "Settings"           , LCDML_FUNC);
  LCDML_DISP_add      (9  , _LCDML_G1  , LCDML_root_4_1_2  , 1  , "Warm"               , LCDML_FUNC);
  LCDML_DISP_add      (10 , _LCDML_G1  , LCDML_root_4_1_2  , 2  , "Long"               , LCDML_FUNC);
  LCDML_DISP_add      (11 , _LCDML_G1  , LCDML_root_4      , 2  , "Program 2"          , LCDML_FUNC_p2);

// ********************************************************************* 
// LCDML BACKEND (core of the menu, do not change here anything yet)
// ********************************************************************* 
  // define backend function  
  #define _LCDML_BACK_cnt    1  // last backend function id
  LCDML_BACK_new_timebased_dynamic (0  , ( 20UL )         , _LCDML_start  , LCDML_BACKEND_control);
  LCDML_BACK_new_timebased_dynamic (1  , ( 10000000UL )   , _LCDML_stop   , LCDML_BACKEND_menu);

// *********************************************************************
// *********************************************************************
  void setup()
    // serial init; only be needed if serial control is used 
    while(!Serial);                    // wait until serial ready
    Serial.begin(9600);                // start serial    
    Serial.println(F(_LCDML_VERSION)); // only for examples
    // Enable all items with _LCDML_G1
    LCDML_DISP_groupEnable(_LCDML_G1); // enable group 1
    // LCDMenu Setup

// *********************************************************************
// *********************************************************************
  void loop()
    // this function must called here, do not delete it

// *********************************************************************
// check some errors - do not change here anything
// *********************************************************************
# if(_LCDML_DISP_rows > _LCDML_DISP_cfg_max_rows)
# error change value of _LCDML_DISP_cfg_max_rows in LCDMenuLib.h
# endif
# if(_LCDML_DISP_cols > _LCDML_DISP_cfg_max_string_length)
# error change value of _LCDML_DISP_cfg_max_string_length in LCDMenuLib.h
# endif

thanks frostedfocus

i got this come up

Arduino: 1.8.2 (Windows 10), Board: “Arduino/Genuino Uno”

C:\Users\karen\Documents\Arduino\sketch_may11a\screen_1.ino: In function ‘void setup()’:

screen_1:63: error: redefinition of ‘void setup()’

void setup()


There can be only one setup() function in a sketch. Find the other(s), merge their code to the one setup() function and get rid of the extras.

groundFungus: There can be only one setup() function in a sketch. Find the other(s), merge their code to the one setup() function and get rid of the extras.

im sorry i dont agree, i have built alot of codes with more than one setup function and the example i posted with the menu code has setup functions for various aspects, if they are naming it correctly then it works perfectly fine, it is possible to also activate and shutdown control to various setup fuctions just by selecting correct menu options provided. its one of the fuctions of a micro controller when using eeprom and textfinder.

im sorry i dont agree, i have built alot of codes with more than one setup function

Disagree all you like, but the only way you had multiple functions with the same name was if they were in separate namespaces or in separate compilation units and qualified "static"

(@Frostedfocus: is there something wrong with your shift key?)

You can only have one function called setup() ! If you have setup() and xxx_setup(), that's another story.

you can take that void setup() and make it into two seperate things by adding a name where XXX is. "void XXX_setup()" Something like that, or you can merge the setup if you wana start mixing up your setup functions like groundfungus said. if you are using just the LCD screen then you will use alot of pins for functionality, if you buy a piggy back then you will only need 2 pins. i have a lib for lcd screens with piggy back that searches for the I2C name and activates it buy itself, its very easy to use. ill send it to you if you want to use a piggy back.

PS void_ setup() is void_setup() yes, if you have a gay man and a straight man they both still sleep with somebody and they both still men. My point being an object is used to preform a job if you need the same job done with different parameters then they will have different names. Bare in mind not everybody has the same experience as you and sometimes it helps people to understand things better if you change the explanation. not everybody has got a degree in electronics or software and sometimes in order to help somebody then it is better not to confuse them with technicalities.

Grumpy Mike's merging code tutorial