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 ~).
498 questions
0
votes
1
answer
1k
views
More than 4 PWM output at 25khz?
Is it possible using an arduino to control more than 4 PWM fan at 25khz ?
I have found this but 4 PWM limited with an UNO
https://arduino.stackovernet.com/fr/q/8407
An other arduino, like a 2560 ...
1
vote
2
answers
568
views
PWM of a frequency signal?
Working on my first real sketch, so will try to keep this short. Feel free to ask more info if needed.
To power a flyback transformer I need to apply PWM -to- a PWM signal. The easiest way to ...
1
vote
1
answer
256
views
Increase PWM bit resolution on only one timer 2 output
I am new here and I know that this basic question has been answered in the past but what I want to know is this. And I cant figure out how to add this to one of those threads. Sorry in advance if I am ...
0
votes
3
answers
2k
views
Using delay(1000); without influence on analogWrite?
So, I'm trying to read the voltage on analog pin A0 and make a "regulation", where if the voltage will be lower than 2.5V (analog value 512), then it should be output pin 9 used as PWM with duty cycle ...
-3
votes
2
answers
2k
views
1-10 volt analog signal
I have an Arduino project where I am using an ESP8266 (Wemos D1 mini) powered via USB. I want/need to output an analog voltage from 0 to 10V.
Goal:
A solution that is pre-made (eg a shield or ...
0
votes
2
answers
274
views
Sending arduino signal to another arduino
I'm working on a project which consists of 2 different function. since the arduino only can do 1 function so i decide to use 2 arduino instead. my idea is 1st arduino will give a output and the sketch ...
2
votes
2
answers
4k
views
How close to 5 kHz can I set the PWM frequency on an UNO pin 11?
I'm rebuilding a laser CNC machine and using LaserWeb4 as the control interface and GRBL 1.1 as the low-level interface to the stepper motors, limit switches and the laser. I have all the motion ...
2
votes
2
answers
14k
views
How do I set a 25 kHz PWM signal on an ESP-WROOM-32?
I want to control a single pin of an ESP-WROOM-32 to have a 25 kHz PWM signal. How do I do that in Arduino Studio? I compiled a "hello world" program for such a device successfully in Arduino Studio, ...
0
votes
1
answer
2k
views
Can adjustable constant current/voltage source be made with Arduino?
I would like to create a 18650 battery automatic management system that can handle and restore used up cells using solar panels for power. To do that I need to create adjustable constant current ...
1
vote
1
answer
141
views
Software Gate on a PWM port
I'm using a PWM port and outputting a freq. Is it possible to pulse the PWM port using software to simulate a pulse gate. For example, I'd like to output a freq of 111hz, but would like to gate that ...
0
votes
1
answer
112
views
Help me determine the power consumption/rating of the circuit below? [closed]
Please help me determine the circuit's power consumption from the battery and help me outline the steps to calculate?
3
votes
1
answer
340
views
Timer interrupt triggers too often
The following question is based on the Arduino Pro Mini (8MHz, 3.3V)
I'm in process of developing (yet another) LED strip driver shield. For that I wrote a simple control loop, that adjusts the ...
2
votes
1
answer
2k
views
Generating 200 kHz pulse on Arduino Uno in normal mode
I need to obtain 200 kHz from Arduino Uno. I am using Timer0. I have configured it to run in normal mode and the Prescaler is set to clk/8 (the clock frequency of Arduino is 16 MHz). TCNT0 ...
0
votes
2
answers
968
views
Inaccurate PWM Signal Frequency and Timing
I have a Teensy 3.2 and I am using the Arduino IDE to program it. I am trying to generate 8 pulses with the frequency of 40 kHz and this needs to be repeated every second. I have written 3 different ...
1
vote
2
answers
1k
views
How to read OC0A when in CTC (toggle) mode?
I have this code, which puts the Arduino into CTC mode with interrupts, and outputs a square wave on PD6 (OC0A):
void setup_timer(double p_ms, double duty){
DDRD |= (1 << 6); // set pin 3 as ...
0
votes
2
answers
335
views
Unable to obtain pulse train at 32Hz with 20us pulse width with Uno
I tried to obtain 32Hz pulse train(between 30Hz and 35Hz is also fine) with around 20us pulse width with Arduino Uno but couldn't succeed. The problem is:
If I do the following:
void setup() {
...
0
votes
1
answer
3k
views
PWM fans causing temp sensor erroneus values (interference?)
I am learning Arduino programming and my current project for real use is to connect 10-17 PC chassis PWM fans to be temperature controlled by the arduino.
So, I have connected the fans exactly as in ...
1
vote
2
answers
293
views
Help - Atmega328p, converting a PWM servo code from pin9 to pin6
I found a working code that uses pin9 (PB1) on my Arduino for controlling a Servo, but in my project, an ultrasonic sensor is already using that pin/timer. I want to convert the code to use pin6 (PD6),...
1
vote
0
answers
213
views
Motor unexpectedly moving at reset
I'm playing with the standard L298N motor board and Arduino MKR 1000. However something strange happens: when I upload a new firmware and when I turn on the Arduino power supply (every time Arduino ...
0
votes
2
answers
4k
views
How do you convert PCM to PWM?
I'm a beginner and I've been developing my own library for a wave player. so far I have the SD card installed and OLED and rotary encoder all connected. I've successfully read the wave chunk and it's ...
-1
votes
2
answers
916
views
generate two phase-shifted PWM pulses triggered by frequency-divided external signal with Arduino uno?
I have a 4kHz pulse as trigger and I need two phase-shifted PWM output with divided frequency from arduino uno.
Now I've managed one PWM output using the following code:
int cnt = 0;
void setup() {
...
0
votes
1
answer
1k
views
PC Fan Speed Control [closed]
I am working on a project to blow air gently through a number of pipes and variable speed. I would like to use a standard PC case fan and have control of whether the fans are on/off and also what ...
-1
votes
1
answer
2k
views
PWM should be applied to ENA or IN1/IN2 for L298N board for speed control
I am new to the Arduino stuff and I am using L298N to drive two DC motors. When I searched online for sample code, I noticed that there are two types of design.
One type uses analogWrite(pin, ...
1
vote
1
answer
279
views
Fast PWM working with int main(void) but not with void setup()
board: Arduino Mega (ATMEGA2560)
I want to generate pulses using timer1 configured as Fast PWM, this is my code which works fine:
#include <avr/io.h>
int main(void)
//void setup()
{
DDRB ...
0
votes
1
answer
390
views
Use SD Card while Pin 11 is being used for PWM
On Arduino Uno Rev3, I just ran the speaker_pcm demo that used TIMER1 and TIMER2 to generate a PWM wave. However, this means that the Pins 3, 9, 10 and 11 can not be used anymore; according to the ...
0
votes
1
answer
662
views
STM32 VGA Output - don't understand why lines are jagged
I am using "blue-pill" STM32F103C8 (http://wiki.stm32duino.com/index.php?title=Blue_Pill) to create VGA output. I am connecting PB6 to VSync, PB0 to HSync, and PA0 to red using 278 Ohm resistor.
I ...
1
vote
2
answers
2k
views
How to test if PWM mode is working correcly?
I d'like to test if the PWM mode is working correctly on the pins of my Arduino Board. Do you know a simple schema to do this ?
3
votes
3
answers
7k
views
Arduino Code for Pulse Skip Modulation (PSM)
I have recently bought this light dimmer, and only when I received it I noticed it works with PSM (Pulse Skip Modulation) and not PWD (Pulse Width Modulation).
Does anyone know how to write Arduino ...
0
votes
1
answer
730
views
How to fade out RGB strip?
I have a NodeMCU controlling an RGB strip. I have followed a guide and used this code:
#include <ESP8266WiFi.h>
#define redPin 13 //D7 - Red channel
#define grnPin 12 //D6 - Green channel
#...
1
vote
0
answers
757
views
Use PWM to play notes on ATMega328
I have old speaker which I want to use to play sound. I chose to use PWM mode on ATMega328 (which is in turn on Arduino Uno R3 board) in order to do it.
For signal on the speaker I chose rectangular ...
-1
votes
1
answer
1k
views
Generating Sinusoid Signal of 40khz [closed]
I would like to generate a sinusoidal signal of 40kHz using Arduino Uno.
Maximum I could generate was 1kHz, using bit banging, fast PWM. Do you have ideas of how to boost it to 40kHz?
I used "...
0
votes
2
answers
148
views
What is wrong with this code?
So I am writing code to control a servo with an RC radio. I am using an Arduino Mega. I get this error whenever I compile. I am not that experienced with Arduino so I am probably not doing something ...
0
votes
1
answer
176
views
Switch between timer2 and manually setting output of pin 3
I have a 62.5 kHz square wave created by timer2 on the pin 3. I would like to be able to use digitalWrite(3, HIGH) to force pin 3 high for several clock cycles, but then I would like it to return the ...
0
votes
2
answers
2k
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
2
answers
594
views
Hold all "millis()" values in an array?
I'm working on a project where I could have up to six devices connected to an arduino, it might be the case that not all of them will be attached at the same time, and all of them need to be able to ...
0
votes
1
answer
187
views
how to make this work auto on off led with fading [closed]
I'm working on a project with Arduino to make LED timer with fading feature. After doing some research finally I wrote some code but it's not working until now
P.S i don't have any knowledge in coding ...
1
vote
1
answer
1k
views
Arduino MEGA 2560 - PWM in case statements not working
So I am using Arduino to control RGB Strip light, the analogueWrite(Pin,Value); Works with the prebuilt AnalogueWriteMega example - on pins 8, 9, and 10.
When I move this into my program, Pin 8 still ...
2
votes
2
answers
6k
views
Can you use digital pins as PWM output?
I am currently working on a robotics project that requires 16 PWM outputs to control 16 servos. Is it possible to use Arduino Uno's digital pins as PWM output pins through code?
If it is not possible,...
1
vote
1
answer
1k
views
Log vs linear pots and the arduino [closed]
I have noticed that when I used a log pot from a guitar amp I found, it gives janky results when using it in a motor PWM sketch, but if I use it in a fade sketch, it works. why does log pots give ...
1
vote
1
answer
4k
views
PWM output while using I2C with the ATTiny library
I've noticed that when using the USI interface on the ATTiny to send I2C via the methods from "Wire.h" with the ATTiny Arduino implementation included from the library manager (ATTinyCore), while ...
1
vote
1
answer
55
views
Platform-independent functions for FastPWM?
I learned from answers here that pinMode(0, OUTPUT) is a platform-independent equivalent of DDRB = 1<<DDB0, on the ATTiny85.
Are there platform-independent functions for the following?
TCCR0A =...
2
votes
1
answer
225
views
LED fade class strobes for unknown reason
Okay, so here is what I'm trying to accomplish:
I have four LEDs, under my fish tank, that I want to fade in and out. I want each LED to fade at a different rate, start at a different "brightness" ...
4
votes
1
answer
299
views
Arduino uno PWM CTC mode - strange behaviour on interrupt
i have this simple code that i use for generating a square wave signal of 125 KHz on pin 9 using Timer1 in the "Clear Timer on Compare Match (CTC) Mode".
I also use Timer1 Compare Match A interrupt ...
1
vote
3
answers
2k
views
How to produce 6 PWM signals with 60 degrees phase shift?
How to produce 6 PWM signals with 60 degrees phase shift using Arduino Uno 6 PWM pins like in the image below?
1
vote
2
answers
7k
views
I can't control my DC motors speed with analogWrite()
I have Arduino Uno and I attached it to 2 DC motors with L298N bridge.
I want to control the speed of the motors so they don't move at maximum speed.
I use analogWrite() but it does nothing,and the ...
1
vote
0
answers
182
views
Create PWM pulses by comparing the cosine wave with AnalogRead potenciometer
I need generate 4 pulses, for the digital outputs, for example 8,9 and 10,11, at this moment I am using an Arduino Mega.
The pulses have these characteristics:
1) 8 and 9 are the same pulses, but I ...
5
votes
2
answers
2k
views
How can I use PWM in power saving mode (ATmega328)?
I fail to use PWM in power saving mode. The output behaves erratically. This should be possible, I guess. The following is a minimal working example:
/* MWE: Cannot use PWM in any power saving ...
3
votes
3
answers
26k
views
Arduino Nano PWM frequency
I have been using an Arduino Nano as a PWM controller for a heating element.
I am currently using D11 (PB3). I could change, although all pins with PWM are in use, and would require a re-write and re-...
2
votes
2
answers
471
views
Controlling two AC devices, device turning on incorrectly
I am making use of the code below to control the speed of an AC fan and the intensity of an AC Lamp with an Uno.
The problem I am having is that, when I set the lamp intensity to low or medium, the ...
2
votes
1
answer
134
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 ...