Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [analogwrite]

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

18
votes
2answers
22k 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 ...
14
votes
5answers
38k views

Is there a way to play sounds from an Arduino without using a sound shield?

I would like to play a wav file (spoken words) from my Arduino. I do not want to add a sound shield. Is there a way to play a sound through an output pin? The quality does not have to be great.
11
votes
5answers
14k views

How to output a true analog voltage at output pin

Regarding my program, it is a program that does some calculations and then outputs a voltage based on the result using analogWrite function. However my problem is that I had done my programming based ...
8
votes
7answers
23k views

What's the difference between analogWrite and digitalWrite?

As the title states. What's the difference between the two? analogWrite(pin,0-255) vs digitalWrite(pin,LOW-HIGH)
6
votes
6answers
19k views

Two Arduinos Send data via Analog Pin?

What I want to do is allow Arduino A to send some constant value to Arduino B. I sense something inherently wrong with my approach, but I cant figure out what it is. So in the diagram below you will ...
6
votes
2answers
84 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 (...
5
votes
2answers
11k views

How to use the analog comparator to determine when an analog pin has reached a certain voltage?

I am trying to find some information on how to use the analog comparator on an Atmega328 to detect when an analog pin has reached a certain voltage (3.16 volts). I cannot find any example code that ...
5
votes
1answer
988 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 ...
4
votes
3answers
16k views

Sending a value from one arduino to another

I wonder if it is possible to send a value from one arduino to another. Basically, I have one arduino measuring let's say weight, but I want to display that value using an lcd in another arduino. ...
3
votes
2answers
4k views

A question about resistance measurement with arduino

Lately I was asking myself about the possibility of measuring a potentiometer resistance with Arduino. My questions are: Is it possible? If it's possible, what kind of restriction does the Arduino ...
3
votes
2answers
933 views

How to implement multiple LED modes in a sketch with potentiometers?

My hardware is 4 potentiometers connected to Arduino Analog 0-3, the output is an RGB led driver connected to Digital outputs 9,10,11. The output channels provide access to PWM control of those pins. ...
3
votes
1answer
218 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 ...
2
votes
4answers
1k 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);
2
votes
2answers
168 views

Direct 5V current based on analog signal

I would like to manage many LEDs from my Arduino - 12 or so - but I do not have the available digital pins to do this. Only one LED needs to be on at one time. Instead, I was hoping to control these ...
2
votes
1answer
631 views

Arduino PWM Frequency - Pros and Cons of Modifying

I am interested in using an Arduino Uno to produce an analog signal by running PWM through an RC low-pass filter. I'll be controlling a highly dynamic object and need a clean voltage signal to ...
2
votes
3answers
642 views

Read Voltage at PWM off time, and Current at PWM on time

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 ...
2
votes
3answers
7k 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 ...
2
votes
2answers
182 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 ...
1
vote
4answers
9k views

Can I turn off a device using the 5V and analog pins?

Could I connect a device that requires minimum 5V 1A from the 5V Pin to the Ground and somehow turn it off inside a sketch? edit: I'm using a Due based boad, the digix http://digistump.com/wiki/...
1
vote
2answers
379 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, ...
1
vote
2answers
996 views

Is it possible to make a mathematical function generator using Arduino?

I want to build a function generator but not the ones which outputs square wave or sawtooth ect. I will input a discrete function lets say f(n) = e^n for n=0 to n=100 and the output array will be ...
1
vote
3answers
1k 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 ...
1
vote
2answers
107 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). ...
1
vote
2answers
992 views

Can I use Arduino to generate a 0 to 15V analog output?

Is it possible to use the analog output pin with some circuit to generate a 0 to 15V analog output?
1
vote
1answer
115 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() { ...
1
vote
1answer
641 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 { ...
1
vote
1answer
460 views

analogWrite causes value from IR receiver to change

I'm playing around with an IR receiver and an RGB led. I had it up and running, until I changed around some code. The remote seeming stopped working, but after looking at the values in the Serial ...
1
vote
1answer
300 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 ...
1
vote
1answer
793 views

Using an Arduino and multiplexer for writing to multiple outputs

I'm attempting to use the multiplexer setup in this article with my Arduino Uno to control the output of LED's, as a way to fully understand the principles of multiplexing. I'm working to modify the ...
1
vote
2answers
362 views

Can i supply the AREF pin with an Analog pin from the same board?

I guess its a dumb question but couldnt find anything about it online. I know its possible to supply the AREF pin with 3.3 V to increase the ADC resolution. For the project i am working on the ...
1
vote
1answer
688 views

Which board/shield to generate (non-PWM) analog outputs?

I am currently building a project involving a laser scanner (two galvanometers with mirrors that deflect a laser beam) that I want to control. The galvos need +-10V differential signals (and I'd like ...
1
vote
4answers
16k views

Issue with PWM output pin

I'm just starting off with using the Arduino and was learning about PWM (http://arduino.cc/en/Tutorial/PWM). Below is what my circuit looks like. Below is the very simple code. const int pinNine = 9;...
1
vote
1answer
253 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 ...
1
vote
1answer
370 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 ...
1
vote
1answer
56 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....
0
votes
3answers
451 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. ...
0
votes
2answers
614 views

Analog output doesn't work for just 2 LEDs [Arduino Mega]

I am having a problem with an Arduino Mega 2560. Everything works fine, the ultrasonic sensors work fine, and the other LEDs work fine. Although there is 2 LEDs who do not work right and when I do ...
0
votes
1answer
2k views

10 bit PWM on Arduino UNO

I am using this code to make 10 bit PWM on port number 9, it seems like everything printed is 0,1022 rather than printing 0, 512, 1023. Is there a problem in my code ? I wired pin9 to A3 to get the ...
0
votes
1answer
96 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, ...
0
votes
1answer
265 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 (...
0
votes
1answer
244 views

PWM output voltage too high

I'm experimenting with PWM with the code below, but (according to my analog multimeter) the voltage on the output pins reach up to 5V whilst the largest analogRead(IN1) value is only around 700: ...
0
votes
1answer
487 views

RGB Led - mixing colors using analogWrite

Currently I'm controlling an RGB LED with my Arduino Nano. I'm mixing the colors using analogWrite Though, the LED's don't light up at all for low analogwrite values and the difference between the ...
0
votes
1answer
3k views

Arduino Due analog output has 500mV offset

I use a simple serial connection to tell the Due what to output into an analog output pin. However, the outputs are offset about 550mV (as seen on an oscilloscope) and the maximum value of 255 gives ~...
0
votes
1answer
50 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 ...
0
votes
1answer
54 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 ...
0
votes
1answer
42 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 ...
0
votes
1answer
796 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 ...
0
votes
1answer
194 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> ...
0
votes
3answers
1k 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 ...
0
votes
1answer
147 views

Generating analog signals

is there a way to make the Arduino act as a voltage source, by generating sinusoidal, triangular and other kinds of signals? If so, can it be done using LabVIEW? (I've already managed reading analog ...