PWM and Digital Pins

I'm building an automatic aquarium which isn't related to my question, but I have already filled up too many pins to bring a 16x2 LCD screen into play. I was wondering what I can do to move the pins around. I have only used PWM pins so far and none of the digital pins on my Arduino Mega.

Basically, my pins that I have filled already are PWM2-9, which only leaves my TX & RX pins, and 10-13, but for the LCD, all the examples I have watched/tried use 5 PWM pins and the TX pin. So I am 1 pin short.

I have:

  • RGBW LED strip which requires 4
  • Switch which requires 1
  • A double relay module which requires 2
  • A temperature sensor that requires 1

Can any of these pins be moved to digital so I can add the LCD screen?

An I2C LCD takes two pins.

Can any of these pins be moved to digital so I can add the LCD screen?

None of those require a PWM at all, they are all digital.

The only item that might require PWM is your ledstrip if you have implemented some dimming functionality.

Hi,

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Can you please post your code?

Thanks.. Tom.. :slight_smile:

Use an i2c LCD, it just uses A4 and A5. Those 1602 LCD modules are sometimes sold with an i2c backpack. Or you can get the backpack separately (they're around a buck each, super cheap). They also integrate the pot for contrast.

BUT - you realize that all analog pins (except A6 and A7 on atmega328p-based boards) can be used like digital pins too, right? This is a common point of confusion because arduino calls them "analog pins" - a better way to think of them is "digital pin with added function of being able to read analog voltages", like how the pwm pins are digital pins that can also do pwm.