I have seen a lot tutorials on L298N motor driver with nodemcu and ESP 32, which are 3.3v logic boards where the motordriver is a 5v logic board, now in Arduino while doing speed control 255 means 5v or even a high means 5v but in nodemcu/ESP32 this means 3.3v, so my question is how it will work ?
1 Answer
It's not a question of voltage. You make a basic mis-assumption:
in Arduino while doing speed control 255 means 5v
No, it doesn't. 255 means "Provide a logic HIGH signal all the time".
128 means "Provide a logic HIGH signal 50% of the time".
The 255 (or whatever number) is the "duty cycle" of a PWM signal. That is a digital signal that can be LOW or HIGH which is switching on or off rapidly. The duty cycle defines the ratio of ON time to OFF time.
You're not providing a voltage - you're providing an ON/OFF signal.
As long as the HIGH voltage of that signal is above the threshold of the receiving device (the L298N in this case) then it will see it as an ON/OFF signal.
According to the datasheet for the L298 the HIGH logic threshold (VIH) is 2.3V. That means anything above 2.3V is seen as ON and anyting below that is seen as OFF (actually there is hysteresis, so it has to drop below 1.5V to switch to OFF).
So your 3.3V from the NodeMCU is above that ON threshold, so the ON/OFF PWM signal is received properly as such.
Incidentally, it's because of this PWM signal that motors make a whining sound when they start up slowly. Because of this most proper motor drivers run the PWM at above 25kHz instead of the 500-ish Hz of the Arduino, so that whine is above the threshold of human hearing.