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
0 votes
0 answers
16 views

Using Timer1 out B for Fast PWM with interrupt on Atmega328P

sorry if my English is not very good. I have an Arduino Nano (equal to uno, Atmega328P) and i want to use it with fast PWM for audio playback (PCM libraries are not enough for me). I want to use ...
Klymins's user avatar
  • 11
0 votes
2 answers
54 views

Translating analogWrite() into PWM duty cycle formula

We can use the function analogWrite(int x) for digital pins which support PWM because any microcontroller has a built in PWM generator.For given x and for Arduino Uno which is the formula to calculate ...
Root Groves's user avatar
1 vote
1 answer
46 views

What prescaler to use for finer control?

I'm using a UNO to generate a 10 kHz PWM signal. I need finer duty cycle variation. The prescalers supported are 1, 8, 32, and 64. void setup() { pinMode(3,OUTPUT); TCCR2A = bit (WGM20) | bit (...
Pranav Pillai's user avatar
-1 votes
2 answers
152 views

I need a 10KHZ PWM signal from pin 3 and 11 using timer 2

The op of pin 11 should be inverse of pin 3. I used digitalreadfast and digitalwritefast and used simple if else. But the delay is high as 10us. What should i do? I found this code in forum but its ...
Pranav Pillai's user avatar
0 votes
1 answer
76 views

Unable to find PCA9685 module when using the I2CScanner library: no servo movement

I am trying to use an Adafruit PCA9685 servo driver module with an ELEGOO Mega 2560 board. I am supplying the servo driver board with 5 V and tested all the wires to make sure. I tested the servo ...
Blaze48gamer's user avatar
-1 votes
1 answer
65 views

How to output two PWM signals, one of 50% duty cycle, the other 25% duty cycle, from an Arduino Uno?

I need to output two PWM signals, one of 50% duty cycle, the other 25% duty cycle, from an Arduino. Feed both signals into the 2 channels of a PicoScope and measure: a) the time difference between the ...
Regan Corban's user avatar
0 votes
1 answer
40 views

Use TCC1 timer to generate PWM on personnal board built with SAMD21E18A

I'm trying to generate a PWM signal from TCC1. I have a personnal board built with SAMD21E18A. I want to use pin 27 PA30, in my variant.cpp I have this line: { PORTA, 30, PIO_PWM, PIN_ATTR_DIGITAL|...
simon's user avatar
  • 133
2 votes
1 answer
274 views

D1 mini ESP8266 no sound on speaker

I am new to Arduino and microcontrollers, I want to make a tone with my D1 mini and a LSM-50F speaker. But I don't get any output. Any idea what I am doing wrong? Tested it with two D1 mini boards. ...
Louis Eiden's user avatar
0 votes
1 answer
58 views

How to control camera lens by Arduino's PWM? What FOCUS A+, FOCUS A- wires means?

I have a camera lens which I want to control by arduino (like this https://vi.aliexpress.com/item/1005004141070063.html) I have an info about wires description but I can't understand what focus A+, A-,...
Robotex's user avatar
  • 103
0 votes
0 answers
160 views

Teensy 4.1 Synchronized PWM - ADC sampling

I'm looking to drive a high side driver at PWM frequency of 200Hz on a Teensy 4.1 with variable duty. The high side driver current sense pin is connected to an analogue pin on the Teensy. I want to ...
Joe's user avatar
  • 59
1 vote
2 answers
369 views

16 bit PWM on Nano Every

I need to drive a LED strip via MOSFET module. The module needs a high resolution PWM for very dim conditions. How can I set my pin to a 16 bit PWM resolution on an Arduino Nano Every?
awado's user avatar
  • 113
1 vote
1 answer
124 views

Why does a simple LED Blink not work using mbed.h PWM and Arduino Nano BLE?

I have set up a very simple test program to blink an builtin LED using PWM. Following the mbed example and setting the period to 4 seconds (0.25 Hz) and duty cycle to 0.5, the expected behaviour is ...
Ivan Novikov's user avatar
3 votes
1 answer
217 views

Serial plotting a pwm

I'm trying to plot the value of the pwm that increases (every 2 sec) then decreases to compare it to the value of an encoder. I was expecting a continued value (like a step ) during 2 seconds but ...
Lavender Juliette's user avatar
1 vote
1 answer
200 views

How to offset PWM output so it would also have negative amplitude?

So PWM goes from 0 to 5V. How could I do -2.5 - 2.5V? Basically I am asking how to add offset to PWM signal. Should I use operational amplifier? How would I use it? I never had to deal with them, but ...
Name's user avatar
  • 135
4 votes
1 answer
693 views

Bad readings from 12V pwm fan tachometer signal

I have the following circuit: (The Arduino is powered via the USB) The problem is that I the reading from the fan's tachometer signal are incorrect, I tried to add the two resistors as voltage ...
Takata's user avatar
  • 71
1 vote
1 answer
110 views

how to change output PWM based on analog input

I want to give different PWM (D11) signals based on how much voltage is input (A7). How can I change PWM for different analog values? #include <LiquidCrystal.h> #include <ezButton.h&...
hfsrg's user avatar
  • 39
1 vote
0 answers
34 views

Troubleshoot/Diagnose Arduino circuit

I've built the attached circuit with the following changes: I used Arduino Nano I used 10K pot 12V is connected to VIN pin (instead of RAW) the Arduino was connected to the PC by USB for the use of ...
Takata's user avatar
  • 71
1 vote
1 answer
340 views

50% duty cycle PWM signal with calculated frequency

#include <PWM.h> int led = 9; void setup() { InitTimersSafe(); Serial.begin(115200); Serial.println(); variable_freq(); pinMode(A0,INPUT); } void variable_freq() { while(true) { ...
curious_direwolf's user avatar
-1 votes
1 answer
118 views

tone() corrupts the PWM on a different pin

I have to use PWM to control some lights. I do this successfully with: analogWrite(11, 127); for a 50% PWM pulse on pin 11. Now, i also have to have tone() support on my code. When I do: tone(10, ...
user1584421's user avatar
  • 1,395
-1 votes
1 answer
1k views

Controlling a servo without the servo library

I am trying to control a servo without the "Servo.h" library.I am sending using analogWrite() some values to the servo.I know the servo takes input a continuous time signal however I dont ...
appliedSciences's user avatar
-1 votes
2 answers
77 views

why the p-mos is acting as a constant switch when the source is connect to any port in the circuit iam not able find the solution ?i

if my circuit has mistake please refer me the proper image. #define pwm 6 void setup() { // initialize serial communication at 9600 bits per second: pinMode(6,OUTPUT); Serial.begin(9600); } // ...
datta sahu's user avatar
0 votes
0 answers
516 views

ESP32 PWM with extended resolution doesn't work as expected

I have attached an RGB-LED to three output lines of the ESP32 and I'm trying to fade all colors independently. Since it didn't work with my code, I went back to the basic ESP32 ledcWrite_RGB sample ...
PMF's user avatar
  • 1,296
-1 votes
2 answers
135 views

Arduino 75kHz output frequency setup

i don't know how to manipulate arduino uno or mega registers and timers to be close to 75kHz output frequency. Could you help please ?
Teddol's user avatar
  • 85
1 vote
2 answers
164 views

PWM with a TRANSISTOR on flexible LED filament

I would like to create a custom lighting, with PWM capability, powered from battery. I would like to use flexible led filaments, and since those consumes more than 40mA, I can't use them directly on a ...
BruceWawe's user avatar
-1 votes
1 answer
513 views

What should happen when sending analogWrite signal to a non-PWM pin?

I'm a very new to Arduino and any electrical engineering, I'm learning through some Youtube tutorials. Based on my understanding though, sending analog signals to a non-PWM pin would just check for a ...
BlueStarXD's user avatar
0 votes
1 answer
155 views

How to control PWM and digital pins at the same time over ethernet in arduino

I am using Controllino Maxi. It has an Arduino Uno inside it. I am trying to control the PWM pin D0 and digital pin R0 via python code. Below is the code I have upload on arduino: Arduino Code: #...
S Andrew's user avatar
  • 183
1 vote
2 answers
2k views

Changing Frequency of PWM Pin on Arduino Uno

I am trying to change the frequency of the PWM output from an Arduino Uno R3 (Been using Pin 9) to 200 Hz with a duty cycle of 20%. This is for an ESC that is connected to a 12V motor, and I know the ...
wroex24's user avatar
  • 13
0 votes
1 answer
135 views

Creating an AC pulse with arduino and perhaps components

I want to create an AC PWM pulse with arduino. The microcontoller, will be also responsible for specifying the frequency (which will be around 500 Hz). External electronic components can also be used. ...
user1584421's user avatar
  • 1,395
-1 votes
1 answer
356 views

How to correctly set PWM to control servo angle in AVR?

I've stumbled upon timer configuration to handle my sg-90 servo and my Arduino UNO. What I did: Set the prescaler to 64 and mode to fast PWM of 16-bit timer. The frequency is 50hz so the ICR1 is set ...
ErnestW's user avatar
  • 109
0 votes
1 answer
2k views

Teensy 4.1 / 4.0 When to use FlexPWM vs QuadTimer pins to strobe LEDs

I want to strobe 3 LEDs (at independent frequencies and duty cycles) via mosfets with a duty cycle of 0.05%-1% at a frequency range of 24-100 hz. I would like to hold 1% or better accuracy for both ...
Robb Godshaw's user avatar
0 votes
1 answer
2k views

PWM on Wemos D1 Mini (esp8266 chip) does not work

I am working on a hobby project: creating an rc-(radio controlled)-toy car. I'm working with a Wemos D1 Mini (esp8266) microcontroller, L298N H-bridge (for controlling the motor) and I'm using the ...
Stefan's user avatar
  • 103
-1 votes
2 answers
2k views

Perform Volume Control on arduino speaker

I am following this guide to produce tones with the arduino: https://www.arduino.cc/en/Tutorial/BuiltInExamples/toneMelody This uses the tone() builtin function. The connections is that one pin of the ...
user1584421's user avatar
  • 1,395
1 vote
0 answers
48 views

Audio range with custom waveshape

I am planning to use several Arduino to produce audio range analog signals. I need to use custom waveshapes generated on the fly. As far as I understand, there are two paths: Aquiring a DAC, but can ...
huhu roro's user avatar
-2 votes
1 answer
763 views

Using IN1/ IN2 pins for PWM instead of ENA in L298N

So basically i tried providing PWM directly to the IN1/IN2 Of L298n motor driver instead of using ENA pin i got more or less the same result Im using ESP32 with 30000Hz freq for my PWM My question is ...
Naveen Gupta's user avatar
2 votes
0 answers
114 views

On initialising PWM with registers on my Due, why does unrelated duty cycle input influence my output?

I am finding that setting duty cycle on PWM channels 4 or 5 has an influence on whether channel 6 generates output. The following is a design of experiments view of my tests and results, where the ...
J Collins's user avatar
  • 295
0 votes
2 answers
2k views

Trouble understanding min and max parameters for the Servo motor

This picture is from arduino.cc . Could someone please help me understand these parameters min and max? I was using TinkerCad taking input for the angle using a potentiometer (having mapped correctly ...
Harry's user avatar
  • 11
1 vote
1 answer
110 views

PWM and attachInterrupts issues

I'm trying to control the speed of a DC current motor with PWM. I use an arduino UNO to send PWM signal to a mosfet Velleman vma411 to change the average tension of a my motor which is wired to ...
Grégoire Lefebvre's user avatar
1 vote
1 answer
170 views

Breathing LEDs on single PWM pin?

I'm doing a project which is essentially a lighted cube, that communicates status through different colors, where I get this ides [it][1] (having code). So when the light goes below a certain level it ...
Kathberny's user avatar
2 votes
1 answer
257 views

Atmega2560 PWM on PH4

I am trying to convert the following code to output to pin 7 (PH4, OC4B) on an Arduino Mega. The code outputs to pin 6. This code is from a GitHub for the GRBL on the Mega "https://github.com/...
Mr.Spriggs's user avatar
2 votes
1 answer
1k views

How does Arduino Servo.h library manage to output PWM when a Servo motor is connected to a non-PWM pin? [duplicate]

While learning more about Servos, the main thing i have learned is that, Servos (SG90) need PWM signal with the frequency of 50Hz. And the duty cycle of the frequency is used to rotate the angle of ...
CoderBittu's user avatar
2 votes
2 answers
464 views

Arduino fade in/out 5 leds circuit acting wierd

I have a simple arduino project with 5 leds, the project should start with led 1 fade through 50 millisec to reach full brightness, then led 2 and so on until led 5 then turn them all off and loop. ...
AhmedH2O's user avatar
  • 123
1 vote
0 answers
31 views

i have problem in generating pwm in steps

Given below is my loop and it counts 1 to 250 using the push button i just added this part as this one is the main part. I want to make it in steps like one press (push button) SETS IT TO 10 OR 20 ETC....
Xaidi's user avatar
  • 51
-1 votes
1 answer
335 views

Driving higher loads with PWM

My Arduino Pro Micro can source 500mA from 3.3V VCC, when it is USB powered. The chip itself, is rated for 200mA, though, and its output pins for 20mA recommended, 40mA max. I am looking to have 3 PWM ...
Bram's user avatar
  • 199
0 votes
1 answer
185 views

Arduino, generating smaller frequency than 31Hz

I'm controlling a car instrument panel with Arduino using the tone() function, however with Arduino Uno's minimum 31Hz frequency I can only set the speedometer at ~12mph or more. I'd like to be able ...
Piotr's user avatar
  • 3
3 votes
1 answer
297 views

First I2C project - Unable to get any servo movement with PCA9685

I'm working on a project where I need to run multiple servos. For now though, I'm trying to get a single MG90S servo running with a PCA9685 servo driver but I'm unable to get any movement from the ...
johnb7716's user avatar
1 vote
0 answers
220 views

Variable frequency PWM, without changing timers

I need variable frequency output - 0-5000Hz with some duty cycle. I do not want to change timers, because I am using delays, serial and CAN, so I do not want them to be affected by changed timers. I ...
Voyze's user avatar
  • 11
0 votes
1 answer
2k views

Seeeduino XIAO write and read PWM duration (period) using timers

I am trying to communicate between two Seeeduino XIAO (chip: ATSAMD21G18A-MU) by way of TCC capture using register timers. Square wave pulse duration varies from 200ns to 4us. I found these two code ...
MeSo2's user avatar
  • 177
2 votes
0 answers
96 views

Is a PWM phase duration set with OCR1A a reliable way to communicate values to other Arduinos?

I am working on communicating 4 switch states across multiple Arduinos using only one pin. It must be as fast as conceivably possible. Currently I have a master Arduino reading all 4 switches (...
MeSo2's user avatar
  • 177
2 votes
0 answers
399 views

Control output of XL6009 Boost converter with Arduino

I wonder if someone could help me with figuring out how to control XL6009 Boost converter via Arduino. I have this popular board, and it has potentiometer to adjust the output voltage. However, I want ...
Twoface's user avatar
  • 21
1 vote
1 answer
124 views

MC33926 Brushed Motor Driver (Shield/Carrier)

How can I use a MC33926 Motor Driver like it is offered for Arduino to drive forwards, backwards with a PWM and a direction control. The problem is that the MC33926 has Inputs IN1 and IN2 and not PWM ...
cat's user avatar
  • 177

1
2 3 4 5
10