LCD Code Please

"What display?" is the million dollar question :wink:

And some tips:

  • Use the enable pin for PWM and connect IN1 and IN2 to digital outputs. Saves a PWM pin and you get nicer motor movement and less heat.

  • DON'T call something what it does on the Arduino, call it something useful like what you do with it. Aka, not 'pwm1' but 'motor_in1_pin' (or more common in the Arduino world: '. 'motorIn1Pin')

  • And once you start numbering variables, most of the time it's time to use arrays. Although here it's not to bad.

  • Use something smarter for the button with proper debounce etc. I like the Bounce2 library for that.

  • If you refer to an analog pin, use 'A0' instead of '0'. That way you can never confuse digital pin 0 and analog pin 0 with each other.

  • DON'T use macros (#define) for pins. Yes, a lot of tutorials do and yes, it works. But C++ (which the Arduino IDE uses) has a much nicer alternative and that's the 'const' keyword. In case something goes wrong, the compiler will output wayyyyyy more readable errors :wink:

const byte ButtonPin = 8;
const byte PotPin = A0;
const byte MotorIn1Pin = 9;
const byte MotorIn2Pin = 10;