Questions tagged [analogwrite]

The analogWrite() function is used to generate a PWM (Pulse Width Modulation) output signal on compatible pins.

Filter by
Sorted by
Tagged with
0 votes
1 answer
56 views

Is it possible to use analogWrite() using an external Power Supply Unit?

As far as I know, my Arduino Nano can perform analogWrite() ranging from 0 to 1023 for 0 to 5 V respectively, but I want to control a DC motor which requires 9 V for good performance. Is it possible ...
Tapan Gupta's user avatar
1 vote
1 answer
60 views

When I use AnalogueWrite the voltage doesn't vary properly

I have a project where I want to control a pump, I use an Arduino, connected to a driver L298N and I will connect the pin 5, 6, 7 of the arduino to the pin IN2, IN1, ENA of the driver respectively and ...
Nept0's user avatar
  • 13
-1 votes
1 answer
436 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
139 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
1 answer
62 views

IF statement to run even if the requirement isn't met anymore

I have built a flasher for the headlamps on my race car. Whilst it works when I hold the switch down, if I release the switch and the circuit is closed my IF statements requirements are no longer met ...
dav0s's user avatar
  • 13
2 votes
2 answers
432 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
0 votes
1 answer
2k views

Random "Compilation error: Error: 13 INTERNAL: exit status 1". No clue how to resolve or even what causes this error

I am a beginner with Arduino. I have a program that is intentionally simple. The code refuses to compile, spitting out the error Compilation error: Error: 13 INTERNAL: exit status 1. I have gotten ...
Jacob Ivanov's user avatar
2 votes
1 answer
279 views

Getting constant PWM value based on user input from serial monitor

I am trying to get a constant PWM value from the PWM pin based on the user input. For example: the user hits 1, the output PWM value is 100, if it is 2 the output would be 200. This will continue till ...
Dave's user avatar
  • 69
1 vote
1 answer
872 views

Writing multiple inputs to serial port using a while loop

I am trying to get the serial monitor to prompt me to input two settings - the PWM level and the Resonance level. I am being prompted to input the PWM level, but before I can input the Resonance level ...
PrematureCorn's user avatar
0 votes
1 answer
109 views

How fast does the Arduino execute code?

I am using the Arduino Nano every. Take this example where I am measuring two things A and B. Loop{// this loop runs once every second //Read A,B //Change something using analogueWrite which ...
fred's user avatar
  • 101
0 votes
1 answer
88 views

Check pin capabilities at compile time

Are there board-independent functions to check pin capabilities at compile time? I.e. Can the pin be used as output, as in digitalWrite()? Does the pin support PWM, as in analogWrite()? Does the pin ...
Dmitry Grigoryev's user avatar
1 vote
1 answer
2k views

Why do I need to use latin-1 instead of utf-8 when using python with arduino?

When reading and writing with a python serial port connection to arduino, if I don't use latin-1 ('ISO-8859-1'), the results are not as expected. Like if I have int outP = 5; //... int outV = Serial....
user14094230's user avatar
1 vote
0 answers
63 views

Phantom reading

my project is to control led diode and dc motor, test shield buttons, and check system run time. Testing buttons and run time i have done. Deal is with led and dc motor control. I'm getting phantom ...
Jānis's user avatar
  • 59
-1 votes
1 answer
2k views

Can i connect in pin of relay module to Analog pins of arduino instead of digital pin?

Im a complete beginner Im making a project using relay modules and arduino. but all the digital pins of my arduino are filled. I wanted to ask if i can use the analog pins to connect my relay module ...
rohithrathod banoth's user avatar
2 votes
1 answer
237 views

Help with millis to get accurate timing

I'm essentially trying to create a music box which is light activated using an LDR. When it's open a song plays, while a servo rotates a figurine back and forth, and an LED dims and illuminates in ...
TonyStark's user avatar
2 votes
1 answer
88 views

Bitwise write to analog PIN

I am just starting to learn bitwise operands and here is my question. To do this: pinMode (13, OUTPUT); digitalWrite (13, HIGH); bitwise I can do like this: DDRB |= B00100000; //set PIN13 as ...
wotesi's user avatar
  • 123
0 votes
1 answer
772 views

analogWrite(PIN, 1023) <> digitalWrite(PIN, HIGH)

This question is very similar to this one. I'm using an ESP8266 for which the maximum analogWrite value is 1023 rather than 255 for some other Arduino boards, but I believe the principal is just the ...
Peter Jennings's user avatar
2 votes
0 answers
53 views

Very weird bug / odd behavior of OUTPUT

So, I have this code (Arduino Mega): void setup() { pinMode(10, OUTPUT); pinMode(11, OUTPUT); pinMode(6, OUTPUT); analogWrite(10, 50); analogWrite(11, 50); } very basic motor speed control....
Name's user avatar
  • 135
0 votes
2 answers
271 views

Communication between 2 arduino boards

I am not really 100% too sure how to do this but I am trying to make my arduino UNO communicate with my arduino MEGA. The reason why I needed to do this was because I was using the RFID module along ...
The_Indestructible_Cat's user avatar
1 vote
0 answers
83 views

How to write analog signals to control throttle of the ship?

I am using teensy 2.0 as DAC. I am trying to write signals on rudder and throttle of the ship via relay. How can I write these analog signals? Should I specify voltage for every pin? Here is my code: ...
Fourier's user avatar
  • 11
0 votes
4 answers
2k views

Is it dangerous to connect two output pins together?

If I have two output pins, one set high and the other set low with digital or analog write like this digitalWrite(PIN1, LOW); digtialWrite(PIN2, HIGH); and then I short them together using a wire, ...
Mark's user avatar
  • 197
4 votes
1 answer
456 views

MEGA 2560: Simple program - One analogWrite turns off the other

I'm using Windows 10, Arduino 1.8.12 (Windows Store 1.8.33.0) I have an Arduino MEGA 2560 and a red LED connected to pin 4. #define RED 4 #define GREEN 2 void setup() { analogWrite(GREEN, 0); ...
Mark's user avatar
  • 197
1 vote
1 answer
1k views

"Manually" generating a PWM signal

I've been trying, just out of curiosity, to write my own function that generates a PWM signal, just like analogWrite(), and to make it light up an LED. Here's my attempt so far: const int pin = 3; ...
Vinícius Peixoto's user avatar
-1 votes
1 answer
851 views

Attiny85 simple analog and digital output problem

I'm just lighting up an LED through a TIP31C, pin 0 goes through a 560kohm resistor to the tip's input pin pin 1 goes through a 750 ohm resistor to the tip's input pin ^i'm not sure this information ...
Valkor Simpson's user avatar
2 votes
1 answer
269 views

Is analogWrite() not affected by blocking codes and/or Interrupts?

Well just as the question say, is the analogWrite() function will continue generating near-consistent PWM when it encounters blocking codes or signal interrupts? Is it the same case for both the ...
Jack's user avatar
  • 213
1 vote
0 answers
410 views

analogWrite and For Loop Bug

I wrote the following code that outputs a packet data structure bit by bit. I do this using two for loops. These two for loops should always terminate, but the presence of analogWrite() makes them ...
MonsieurRisch's user avatar
1 vote
1 answer
2k views

L298N beeps and malfunctions when receiving certain analogWrite values

I created a simple circuit with an UNO, L298N and a single motor. Wrote the following code to test controlling the speed of the motor. Tested motor with digitalWrite() function and it works fine. ...
yannism's user avatar
  • 21
1 vote
1 answer
418 views

AnalogWrite problem

I have connected DRV8835 with 2 DC motors with 11 power supply. Arduino nano. When I for loop like i from 0 to 1024 for analogWrite(i,Motor1) for the DC Motor1 it's accelerating from 0 to 200 and it'...
Lary's user avatar
  • 13
0 votes
1 answer
243 views

Replicate output of pwm pin on another output pin?

Ardiuno Mega 2560 I have a legacy PCB that connects PORTA, pins = {22, 23, 24, 25, 26, 27, 28, 29} to the PWM input of a set of actuators. The accompanying code made use of an interupt service ...
DrBwts's user avatar
  • 161
0 votes
2 answers
255 views

How can I create an analog signal which is similar to PMT (Photo Multiplier Tube) pulse using analog write? [closed]

I have developed a circuit to process the PMT pulse output. For the testing, I need an artificial signal which is similar to the PMT pulse. How can I use AnalogWrite() to create such type of signal?
krishnamoorthi jayakumar's user avatar
1 vote
1 answer
283 views

Cannot get esp8266 - 12 wifi module to always read analogRead incoming voltage accurately

So I have and arduino uno that is firing an output on pin 8. This code is not in this file just to be clear. From there Im taking that output and using it to fire pin 0 on the wifi module. Im using ...
user52703's user avatar
0 votes
1 answer
521 views

Reading analog value while generating PWM signal

I'm trying to generate dim two LED strips simultaneously by generating two PWM signals based on potentionmeter value. The pot sets how bright each of the LED strips will be. To drive this I'm using ...
jnovacho's user avatar
  • 235
0 votes
3 answers
10k views

Passive buzzer works with analogWrite(), but not with digitalWrite(). It also has constant static noise

I have a YL-44/MH-FMD passive piezo buzzer hooked up to an ESP8266/NodeMCU. It's connected like this: Buzzer ---> NodeMCU - GND ---> G - VCC ---> 3V - I/O ---> D2 This code makes a clear beep. ...
Ivan's user avatar
  • 115
1 vote
1 answer
209 views

Help with simple gradually brighter flickering led

im a newcomer for arduino and sorry for any grammar error. So what im trying to do is replicating a flickering effect found on spacecraft thruster when they about to take off where the fire bursting ...
user194312's user avatar
0 votes
1 answer
2k views

setting output analog/digital pin to ground

So I need to automaically eject a CD from a Blu-Ray drive, I have a wire welded on the drive's card that if manually connected for a split second (pulse) to the ground of that same card on the drive, ...
SalmaG's user avatar
  • 3
7 votes
2 answers
196 views

How can I differentiate between multiple circuits?

I'm building a puzzle for an escape room. I want to give the user 6 wires and 6 terminals, then confirm that they've connected the correct wires to the correct terminals (one-to-one). My first (...
Jonathan Dautrich's user avatar
3 votes
4 answers
8k views

Writing analog voltages on analog pins of Arduino

Can we write a analog voltage to analog pins A0-A7 of the Arduino Nano (for example)? As in: pinMode(A3, OUTPUT); analogWrite(A3, 200);
Nishanth Rao's user avatar
3 votes
1 answer
751 views

Noise when running Arduino close to analogue audio circuit

TL;DR: My Arduino is injecting a lot of noise into an analogue audio circuit, even when not physically connected. I'm experimenting with using an Arduino as a low-frequency oscillator in audio ...
helveticat's user avatar
0 votes
2 answers
5k views

Dim a led using a NPN transistor

I know there are a lot of questions about this topic, but I've tried everything and any possible guide online without success. I want dim (increase and decrease the brightness) some leds (3.5 Watt ...
xdola's user avatar
  • 103
1 vote
2 answers
2k views

Can only write 5V or 0V, not something in between

I'm working on a bigger project, and needs to give out a voltages between 0 and 5V. I've written this code: int ledPin = 12; // LED connected to digital pin void setup(){ pinMode(ledPin, ...
Erlend Salte Kallelid's user avatar
-1 votes
1 answer
2k views

analogWrite(DAC0, X), Analog voltage on DAC0 pin is higher for lower X value - is this normal?

I am using an Arduino DUE. Using the analogWrite(DAC0, X) command I am writing an analog value to this pin. X = 0 - 255 as I understand it. I am observing that when X is lower, the voltage on DAC0 ...
user avatar
0 votes
1 answer
600 views

AnalogWrite only working for one pin of RGB LED

I'm working on some code for a Nerf blaster with an LED indicator light. When attempting to use analogWrite to PWM my LED pins, only one pin (blue) behaves as expected and dims down. The other two (...
jjumbc's user avatar
  • 1
1 vote
1 answer
324 views

How can I make an AC analog voltage with Arduino?

I am trying to create an AC voltage in Arduino. Until now I have only managed to get a square wave. How can this be achieved with Arduino? If I try: int up; int down; int out = 11; void setup() { ...
Anonymous's user avatar
  • 111
1 vote
2 answers
5k 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 ...
Mustafa Mohamed's user avatar
0 votes
1 answer
271 views

how to break out servo.write(angle) after it reach the angle?

I used a servo as a grabber so I don't know the angle I need specifically.I need it to break the serve.write(angle) when the grabber holds something. I used a simple code #include <Servo.h> ...
Mostafa Rady's user avatar
2 votes
3 answers
2k views

Is it possible to obtain %0.05 duty cycle at 1hz in arduino?(a 500us square pulse at 1 sec period)

I have a system which requires me to obtain different duty cycles at different frequencies. But using the analogWrite() does not allow me to obtain a value lower than 1/255 duty cycle. I need to ...
allta's user avatar
  • 23
2 votes
2 answers
189 views

A beginner lost at sea, Arduino looking at the sun [closed]

I am working on trying to make a LED strip respond to natural Light levels for a sculpture. I have reached a problem in trying to get the code to work when sending PWM to the light strip. Thank you ...
David's user avatar
  • 29
1 vote
3 answers
2k views

Reading an output analog pin with an input analog pin

I am having a hard time understanding why I can't read one analog pin's output with another analog pin. The docs state to put a delay in between, which I've done (I've tried up to one second with the ...
stevieb's user avatar
  • 296
2 votes
2 answers
245 views

for loop reads pots, passes value to PWM pins, can this be in the same for loop?

In the code below I am using a for loop to iterate over analog pins (potentiometers) and pass their value, after being mapped, to PWM enabled analog output pins (currently controlling LED brightness). ...
caseyanderson's user avatar
1 vote
1 answer
608 views

analogWrite mosfet problem

i have a custom atmega328p board which have connected to pin 9 the gate of a MOSFET. If i run a simple sketch like: void setup() { } void loop() { analogWrite(9,70); } The motor connected to the ...
user3106888's user avatar