The Different of Generating PWM Frequency in Arduino Board
arduino uno - Can I use the PWM pins as regular digital input/output pins? - Arduino Stack Exchange
Does the Arduino Nano and Arduino Uno have the same pin mappings?
arduino uno - Can you use digital pins as PWM output? - Arduino Stack Exchange
If the Arduino Uno have the mapping of 3,5,6,9,10 and 11, The pins 3, 9, 10 and 11 generates PWM frequency of 490Hz and pins 5 and 6 generates PWM frequency of 980Hz... how about the Arduino Nano? some forum says that D3, D5, D6, D9, D10, D11 but the D3 pin are used for the reset button? I'm so confused. Lately I've made a code to replace the blown controller IC on a solar fan that I've bought last 6 months ago. I figured out I could just replace it's microcontroller but with a more powerful and advanced one. Initially I was gonna use the Arduino Uno, but changed my mind as it won't fit. So I moved on to using the nano, in which I'm incapable of knowing the PWM pins that could go from 0Khz to its maximum 6.25Khz (or 8Mhz I think) of PWM signal it could produce. If anyone could help me, I'd appreciate it a lot. Thanks!
//Button Remapping
const int Speed_FanuP = 2; //Button Pin for turning up the speed
const int Speed_fanDOWN = 4; //Button Pin for turning down the speed
const int Osc_turn = 7; //Button Pin for letting the fan oscillate horizontally
const int Integ_LED = 8; //Button Pin for Built_In_EmLight, I'd like to use this pin to fade in/out the LED and stay on.
const int Timer = A0; //Button Pin for 30Min_Timer (assign as digitalWrite)
// Physical Pins for Components
const int StatusLed_Pin = 13; // Green LED status Pin, I'd like to use this pin to fade in/out the LED and stay on.
const int Built_In_EmLight = 12; // Built in 6v LED light, I think it's okay that I've used 12th pin for this since I just need to turn it on/off
const int Variable_MosfetFan = 11; // For IRFZ44N (demo only) or any other N channel type of mosfet
const int Fan_Horizontal_Osc = ?; //just a simple motor, no need to change the speed as its only were to use as to spin the fan left right
I'm not sure if I were to use const int in all of the variables... isn't it redundant if I were not even to even change the pins?
Only specific Digital Pins marked with ~PWM can generate a PWM signal. In the case of arduino Uno the pins 3,5,6,9,10,11 are all hardware PWM driven, and are marked on the Uno with a ~ or something. Others can be driven with software PWM(though I wouldn't recommend it). As the Arduino Uno uses the ATMEGA328P, the number of pins is same with other boards using same processor.
On the other hand if you want to run 16pins for PWM, its best if you use Arduino MEGA 2560 because its processor supports more than 6 Hardware pins for PWM. Also you get the advantage of a higher memory storage for your code
PWM is not used to control servos. Servos need a pulse that is 1 to 2 ms wide, with 1.5 ms wide being the center position, that occur every 20 ms (50 Hz).
A 2560 has enough timers and the library to control up to 48 servos.