Create extra digital pin (PWM)

Hello, i am a new user of the Arduino mega 2560 r3. Standard on this board you have 8 digital pin (PWM) availble. But for my new project a need at least 18 digital pin (PWM). I want to connect the mebrance switch module, 2x L9110 H-bridge motordriver and 6x micro switch.

Can someone explain or advise me how to create more digital pins with PWM?
Or how using the other (normal) digital pins?

Thanks in advance, Jeroen (from NL)

Why do you need a PWM pin for the Microswitches?

also pins that are PWM 2 - 13, 44, 45 & 46

If you need so many PWM pins for real, you might could use this


I don't know what other possiblities there are. I have a starterskit and practice with some examples and I see everytime they using the PWM pins.
I don't know how to use other ports, so please advise me in this

There are many tutorial examples supplied with the IDE.

I'm a real beginner so where can I find a good tutorial that gives a simple explaination of all the different types of pins on my board and how I can use them in a project?

The Mega R3 has 70 digital pins.
Switches usually use a digital pin with pinMode (pinX, INPUT_PULLUP); to set them as inputs, and do not need PWM.
The membrane switch module does not need PWM pins.
The L9110 only needs 2 PWM inputs per chip. A two-chip board would only use 4 PWM pins. The other control signals used are not PWM.

All pins can be used as digital input or digital output; read up on

A number of pins have so called alternate functions; read up on
analogWrite (PWM)

Other alternate functions are uart (serial port), SPI and I2C.

You can further play with the examples that come with the IDE and try to understand them.

Hallo Jeroen, it is confusing for us.

The Arduino Mega has 15 PWM pins.
But we don't understand why you need 18 PWM pins. What do you need them for ?
Can you make a drawing of how everything is connected and make a photo of that ?

We have the impression that you think you need PWM, but you don't.

If you really need them, there are libraries that can create a PWM signal on normal digital pins. Using that library has a lot of consequences, and you probably don't need so many PWM signals in the first place.
For example this library:
But that is a highly optimized library that takes over the Arduino board. You will get into so much trouble if you use that.