Questions tagged [pwm]

PWM is a form of signal modulation that allows digital output to approximate an analog signal. Use this for questions about using the PWM pins (marked with ~).

Filter by
Sorted by
Tagged with
9
votes
2answers
44k views

Set PWM frequency to 25 kHz

I currently can set four PWM pins to around 31 kHz with the following code: void setup() { TCCR1B = TCCR1B & B11111000 | B00000001; // Set PWM frequency for D9 & D10: pinMode(...
22
votes
1answer
41k views

What is the frequency of PWM output on Arduino

What frequency do Arduinos use for normal PWM when you use analogWrite()? And is it different for different Arduino model? I'm interested specifically in the Mega 2560, but also want to know if it's ...
5
votes
1answer
1k views

Why does an LED sometimes flash when increasing brightness?

This is admittedly a cross-post from LED fade malfunction (random flash) but I can't get an answer on the Arduino forum. I was mucking around with some very basic code and I noticed that when ...
5
votes
4answers
13k views

Can I connect a PWM pin on one Arduino to an analog input on another?

I was considering several different ways to send simple data from one Arduino to another when I though, why not connect a PWN pin of one Arduino to the analog pin on another? I could send simple ...
4
votes
2answers
4k views

How to increment and decrement an output voltage by using two buttons?

I'm trying to create a code using an Arduino Uno board to increment and decrement the output voltage of the Arduino Uno which is 5 volts and I need to step it up to 10 volts which I have done below. ...
9
votes
2answers
26k views

Increase PWM bit resolution

I would like to increase the PWM bit resolution of the Arduino Uno. At this moment it is 8-bit which I consider too low. Is this possible without losing the ability of interrupts and delays? Koen ...
8
votes
2answers
9k views

How precise is the timing of pulseIn()?

I've been using the pulseIn() function for processing PWM-based binary data encoding. It works well for distinguishing pulses which are significantly different lengths, e.g. 500us vs. 1500us. That ...
3
votes
4answers
7k views

Transistor amplifier to drive speaker using Arduino PWM [closed]

I have been working on a project lately which uses Arduino to play a wav file from SD card. I am using TMRPCM library which made the job very easy. But the problem is that the output sound in the ...
20
votes
2answers
23k views

Why do some pins have a different PWM frequency?

According to the Arduino reference for analogWrite(), the PWM frequency on most pins is ~490 Hz. However, it's ~980 Hz for pins 5 and 6 on the Uno, and for pins 3 and 11 on the Leonardo. Why are ...
3
votes
2answers
25k views

How to control 19 RGB LED strips with one arduino?

I need to light up 19 RGB LED strips, which it seems would require 19*3=57 PWM outs and 57 transistors. The transistors aren't an issue, but of course the 57 PWM's is. Even if I hacked the digital ...
3
votes
2answers
599 views

Can a timer be used in both CTC and (fast) PWM mode simultaneously?

I would like to generate a sequence of pulses of varying lengths in the range of 0-100us, so that from the start of one pulse to the start of the next there is a delay of 100us. I have set up timer0 ...
2
votes
2answers
7k views

Why is my interrupt code not working?

Background I'm trying to write code to read signals from a six-channel RC receiver on an Arduino Mega 2560. Currently I am keeping the code to just read one channel to make things easy to ...
2
votes
1answer
507 views

Controlling ESC with Arduino

I want to control these motors: hexTronik DT750 Brushless Outrunner 750kv with this battery: Turnigy 2200mAh 3S 25C Lipo Pack and these ESCs: TURNIGY Plush 18amp Speed Controller. I am new to this ...
1
vote
2answers
2k views

Arduino read PWM duty cycle value with input (analog / digital)

I am working on comparing autopilots like Ardupilot, CC3D, KK2.1.5. The comparision is about system reactions/behaviors that it gives during flight. For this purpose, I need to read the PWM duty cycle ...
1
vote
1answer
370 views

Trouble with setting the PWM frequency for Arduino Due

I'm using Arduino Due and I set the analog read and write resolution to 12-bit for better resolution. Basically all I do is to vary PWM duty cycle by controlling analog DC input voltage from 0 to 3.3V....
5
votes
1answer
260 views

Help managing the fallout from timer0 mode and prescaler change on ATMega2560 without modifying wiring.c

For a driving application I need the PWM mode to be phase correct and the prescaler to be 1. The issue is that the board I am working with has the load hooked up to a PWM pin reliant on timer0. The ...
3
votes
1answer
1k views

PWM multiplexing on Arduino nano

simulate this circuit – Schematic created using CircuitLab Its a simple project. I am trying to drive 3 RGB LEDs using Arduino Nano. Since Arduino Nano does not have 9 PWM pins, the only ...
3
votes
1answer
4k views

Do I need to use a resistor if I am using a potentiometer to control an LED's brightness?

I am currently tinkering with an arduino, and am using a potentiometer to change the brightness of an LED. I understand that usually, a resistor is added to the circuit to limit the current flowing ...
2
votes
2answers
264 views

Does the square-wave nature of PWM dictate how much resistance you need?

I think the answer is yes, but I wanted to ask the question anyway for future common reference. And to check my understanding. Say I want to power 10 LEDs with PWM with my Mega 2560. I have a bunch ...
2
votes
3answers
8k views

Why does a Piezo Buzzer not require a PWM digital pin (Gallileo Gen2)?

According to my current (poor) understanding, only the PWM pins (with the ~) among the digital pins (ignoring Analog pins) can be passed to analogWrite(). I understand the servo therefore - since ...
1
vote
0answers
421 views

ATtiny Mapping PPM Inputs to Move Servo Issue

Short Version: Not able to get a servo to move to mapped input from RC remote control PPM signal. Detailed Verison: I am trying to take an input signal from a hobby RC radio (D4RII receiver ppm ...
1
vote
1answer
975 views

ISR not working as it is supposed to

For a battery charging project, i am using an ARDUINO UNO which is driving a buck converter to provide the battery with the charging current. I am using external ADCs to measure the battery's charging ...
1
vote
1answer
62 views

Set PWM by period? And have it variable?

In this other stack QA I'm asking about generating a pulse signal with a period ranging from 63 ms to 6.5 ms. There is a popular PWM library however it doesn't compile and also since 63 ...
1
vote
2answers
2k views

How to make precise square wave?

I am playing with stepper motors and I need a precise square wave generator for f=29.710617283951Hz. I've done this on Raspberry Pi without any problems, but I need something smaller and with less ...
1
vote
1answer
112 views

Limiting motors to a specific position using while and if loops

I am currently building a prosthetic hand using an Arduino MEGA, an Advancer Tech Myoware sensor, and 3 TB6612FNG Dual H-bridge breakouts. I have the EMG sensor sending an analog value to the Arduino ...
1
vote
1answer
50 views

Arduino Due custom platform for school and library installation

I have made a custom-development hardware for our school, where you can plug in an Arduino Due. It is mainly for driving all kind of motors and reading sensor signals. Therefore I added a custom SAM ...
0
votes
2answers
556 views

Controlling multiple fans using arduino uno

I'm kind of new on the field of Arduino. Although I have a question concerning multiple fan connection on 1 arduino PWM pin. The goal is to connect around 8 to 16 fans on 1 arduino pwm header pin and ...
0
votes
2answers
3k views

Need help to set PWM frequency to 25kHz on pin 8 of Arduino Mega

I am trying to follow Need help to set PWM frequency to 25kHz and generate the same 25khz on pin 8 of arduino mega which is controlled by TIMER 4; I dont see any success; could someone please help? ...
0
votes
1answer
1k views

Need help to set PWM frequency to 25kHz on pin 8 of Arduino Mega to control speed of a 4-wire cpu fan

This question is not same as the other one and this is more about employing the pwm signal to drive a CPU fan; I am trying to follow the answer by Edgar Bonet on the question Need help to set PWM ...
0
votes
1answer
103 views

PWM delay without blocking the code

I want my LED to turn on gradually without using the delay() function and blocking the code. Here's the code i came up with: int led_pin = 6; unsigned long millisTimer = 0; int PWMdelay = 5000; int ...
0
votes
0answers
60 views

Arduino Every 25k PWM signal

I have written a class for generating a 25khz pwm signal for the Arduino Nano. This works great (pin 9 and 10 only) on the Nano. I want to switch to Arduino Every; this code does no longer work (the ...
0
votes
2answers
2k views

32u4 timer 4 pwm frequency help

I have extracted the following code from the multiwii project. It generates a ~490-500hz pwm signal on pin 6 which is used to drive an esc. I want to change this frequency down to 50Hz to drive a ...
0
votes
2answers
3k views

Controlling common anode RGB LED with PWM - Can individual colors be done w/o transistors?

I am using PWM (analogWrite) with a common anode LED. My previous experience is using a common cathode. My breadboard is as shown: simulate this circuit – Schematic created using CircuitLab ...