I can't get the code to work plz help

So I am trying to make it when the button presses then is does 321 go and then is starts the stopwatch but every time I try it it never works please help Thx :slight_smile:

#include <LiquidCrystal.h>
LiquidCrystal lcd(5, 6, 7, 8, 9, 10);
const int buttonPin = 13;
int buttonState = 0;
void setup() {
lcd.begin(16, 2);
pinMode(buttonPin, INPUT);
lcd.clear();

}
; int counter = 0;
void loop() {
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
lcd.println(“3”);
delay(1000);
lcd.println(“2”);
delay(1000);
lcd.println(“1”);
delay(1000);
lcd.println(“Goooooo!”);
counter = counter + 1;
lcd.println(counter);
delay(1000);
lcd.clear();

}
}

can someone help please

it never works please help

Not a great description of your problem. The code does something. What is the difference between what the code actually does and what you want?

Read the how to use this forum-please read sticky to see how to post code properly and some advice on how to get the most from the forum. Use the autoformat (ctrl-t or Tools, Auto Format) function to indent your code to make more readable.

lcd.clear();










}
}

What is up with all those blank lines. That just makes code harder to follow.

MOmountainbiking:
can someone help please

Really? You posted this a whole 10 minutes after asking your original question? You do realize you’re not paying for help here, right? People are providing it for FREE.

How is the input wired ?

Do you have a pulldown resistor in place keeping the input LOW when the button is not pressed or is the input floating at an unknown voltage which could be HIGH or LOW ? If not then consider using

pinMode(buttonPin, INPUT_PULLUP);

to activate the built in pullup resistor and wiring the button so that the input is taken LOW when prsesed. You will also need to test for LOW to detect the button press.

  lcd.println("3");

the lcd libray does not support println(). It does not go to a new line but prints strange characters. Use setCursor() to set the print position.

Here is my take on what I think that you are wanting to do. Note code posted in code tags and formatted for readability.

I wired the button switch to ground and set the logic to LOW for button pressed which is the accepted way to wire a switch (like larryd says).

#include <LiquidCrystal.h>

LiquidCrystal lcd(5, 6, 7, 8, 9, 10);

const int buttonPin = 13;
int buttonState = 0;
boolean started = false;

void setup()
{
   lcd.begin(16, 2);
   pinMode(buttonPin, INPUT_PULLUP);
   lcd.print("Push to start");
   delay(2000);
   lcd.clear();
}

int counter = 0; //removed useless ;

void loop()
{
   buttonState = digitalRead(buttonPin);
   if (buttonState == LOW)  // changed to use active low button (wired to ground).
   {
      lcd.setCursor(0, 0);
      lcd.print("3");
      delay(1000);
      lcd.setCursor(0, 0);
      lcd.print("2");
      delay(1000);
      lcd.setCursor(0, 0);
      lcd.print("1");
      delay(1000);
      lcd.setCursor(0, 0);
      lcd.print("Goooooo!");
      started = true;
   }
   if (started == true)
   {
      lcd.setCursor(0,1); // reset cursor
      counter = counter + 1;
      lcd.print(counter);
      delay(1000);
      //lcd.clear(); don't use clear, it is slow
   }
}