Hi, I'm very new to Arduino and I have been trying to code something where every time I press a button, the number next to P: on an lcd will go up by 1. To do that I need to have P: (variable), but I can't figure out how to. This is my code attempts so far.
#include <LiquidCrystal_I2C.h>
int ButtonPin = 2;
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup() {
pinMode(ButtonPin, INPUT);
lcd.begin();
}
void loop() {
int buttonInfo = digitalRead(ButtonPin);
int Period = Period + buttonInfo;
lcd.setCursor(12, 1);
lcd.print("P: ",Period);
}