Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

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
0 answers
26 views

Control DC motor speed with external power supply

I am trying to control DC motor speed, using analogWrite(MOTOR,int:speed) command. #define MOTOR D5 void setup() { Serial.begin(115200); Wire.begin(); pinMode(MOTOR, OUTPUT); Serial....
user avatar
2 votes
2 answers
119 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. ...
user avatar
0 votes
1 answer
1k 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 ...
user avatar
2 votes
1 answer
97 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 ...
user avatar
  • 79
1 vote
0 answers
280 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 ...
user avatar
0 votes
1 answer
78 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 ...
user avatar
  • 101
0 votes
1 answer
74 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 ...
user avatar
0 votes
1 answer
361 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....
user avatar
1 vote
0 answers
48 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 ...
user avatar
  • 61
-1 votes
1 answer
507 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 ...
user avatar
3 votes
1 answer
156 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 ...
user avatar
2 votes
1 answer
47 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 ...
user avatar
  • 23
0 votes
1 answer
285 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 ...
user avatar
2 votes
0 answers
50 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....
user avatar
  • 127
0 votes
2 answers
180 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 ...
user avatar
1 vote
0 answers
63 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: ...
user avatar
  • 11
0 votes
4 answers
820 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, ...
user avatar
  • 187
4 votes
1 answer
299 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); ...
user avatar
  • 187
1 vote
1 answer
423 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; ...
user avatar
-1 votes
1 answer
404 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 ...
user avatar
2 votes
1 answer
130 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 ...
user avatar
  • 213
1 vote
0 answers
296 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 ...
user avatar
1 vote
1 answer
1k 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. ...
user avatar
  • 21
1 vote
1 answer
340 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'...
user avatar
  • 13
0 votes
1 answer
149 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 ...
user avatar
  • 149
0 votes
2 answers
197 views

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

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 the AnalogWrite() to create such type of signal....
user avatar
1 vote
1 answer
217 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 ...
user avatar
0 votes
1 answer
366 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 ...
user avatar
  • 235
0 votes
3 answers
8k 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. ...
user avatar
  • 115
1 vote
1 answer
173 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 ...
user avatar
0 votes
1 answer
1k 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, ...
user avatar
  • 3
7 votes
2 answers
159 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 (...
user avatar
2 votes
4 answers
6k 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);
user avatar
3 votes
1 answer
666 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 ...
user avatar
0 votes
2 answers
4k 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 ...
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, ...
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
535 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 (...
user avatar
  • 1
1 vote
1 answer
252 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() { ...
user avatar
  • 111
1 vote
2 answers
4k 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 ...
user avatar
0 votes
1 answer
266 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> ...
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 ...
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 ...
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 ...
user avatar
  • 296
2 votes
2 answers
215 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). ...
user avatar
1 vote
1 answer
546 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 ...
user avatar
1 vote
1 answer
1k views

Why doesn't analogWrite() work

Can anybody tell me why these analogWrite() statements are being ignored. The code is entering the "if"statements because the Serial.println() statements are being executed. class Pwm { ...
user avatar
1 vote
2 answers
452 views

Using ALL the analog pins on Mega for Servo

I wish to use ALL the Analog pins on a Mega2560 R3 to control Servo's, all is well up to and including A9, but from there on nothing. {sound familiar} this is apparently not a new problem. I have ...
user avatar
  • 198
-1 votes
2 answers
5k views

Analog pins for 4x4 matrix keypad

I am working on a project on nano and want to use analog pins for 4x4 matrix keypad input. My connections are for keypad are as follows: Digital pins are D10-D13 and Analog pins are A0-A3. A0->14, ...
user avatar
1 vote
1 answer
603 views

Directly read analog voltage using PWM duty cycle timer registers

I'm outputting an analog voltage by setting an 8-bit duty cycle using analogWrite. Once set, I'd like a way to read back this duty cycle. I've managed to read the duty cycle back from the OCR4D ...
user avatar
  • 215