Is there a way to make the Mega channel 44 to be a PWM?
I’m having trouble accessing the PWM channels on the Mega 2560. That is, I’m trying to get channels 44, 45, and 46 to act like a PWM channel. My program calls on 44 just like channel 2. I ask channel 2 to dim an LED just fine but 44 is only on or off. I then changed 44 in the program to 4, moved the breadboard wire from 44 to 4, and the light started dimming.
Is there a way to make the Mega channel 44 to act like a PWM?
Thanks,
Peter
Yes, but not directly. There are soft PWM libraries, but they tend to be CPU intensive. Google “arduino pwm on any pin.” You’re probably better off rewiring your circuit.
But why do I need a software PWM on a channel that Arduino says is a PWM channel?
I mean the description of the Mega 2650 says it is PWM on channels 2 to 13 plus 44, 45, and 46. But on mine it doesn’t respond to analogWrite on the 44, 45, and 46 channels.
Thanks so much,
Peter
You’re right. My mistake. I don’t know why analogWrite wouldn’t work on a PWM capable pin.
I loaded a short program that just calls 44, 45, and 46 as PWM and that worked OK so the MEGA is working without failure. However, my other complex program still won’t. On the complex program, I then changed the call of two PWM channels stating the opposite was 4 and 44 and the 44 channel then worked.
It is like the use of 44 as a PWM cannot happen while simultaneously using all of the lower PWM channels.
Thanks again,
Peter
Wow, new discovery.
Before I call “servo1.attach(9)” pin 44 acts like a PWM, but then when the program attaches the servo to pin 9, pin 44 stops acting like a PWM.
So what does that mean???
Thanks,
Peter
You didn’t say you were using servo. Complete information is important in troubleshooting. The servo library uses the same hardware timers as the PWM functionality. See this thread: http://forum.arduino.cc/index.php?topic=317353.0.
Ha! You are the man (or woman, as this is the invisible internet).
So despite the advertisement, if you use Servo (with its timer 5) then you lose PWM on 44, 45, and 46.
I am OK with that limitation. I just thought it was me.
Thanks, I’m good now.
Peter