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.

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 ...
1
vote
1answer
53 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
1answer
46 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 ...
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
3answers
442 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
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
95 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, ...
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 (...
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);
3
votes
1answer
214 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 ...
0
votes
1answer
789 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 ...
1
vote
2answers
374 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, ...
0
votes
1answer
698 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 ...
0
votes
1answer
263 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 (...
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
votes
2answers
652 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 ...
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> ...
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 ...
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 ...
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 ...
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
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
639 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
249 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
votes
2answers
2k 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, ...
1
vote
1answer
368 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
789 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
votes
1answer
152 views

What is the definition of these arduino commands, and how do they affect the circuit? [closed]

I don't know if I am allowed to ask this question because really I could just look this up on google. The reason I'm asking here is because in google when you look up the definitions for the following ...
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)
1
vote
2answers
990 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?
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
2answers
309 views

PWM doesn't work with my sketch

I have a weird problem. again. This time it's the PWM. I have used PWM before and I used to work the way I am doing it now. But now it just wont work. The Fading sketch from example works. When I ...
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 ...
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
145 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 ...
1
vote
2answers
361 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 ...
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 ...
0
votes
1answer
243 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: ...
-1
votes
1answer
380 views

The function AnalogWrite is outputting less voltage than digitalWrite on my board

I can't figure out why the output voltage of analogWrite(255) is less than the voltage of digitalWrite(255). My code and an image of my setup are below. Some other useful information is that I am ...
0
votes
0answers
416 views

How to use the timer to generate a pulse wave of the specified frequency and duty cycle

So we have the tone library, which produces a 50% duty cycle square wave of varying frequency, and analogWrite() which produces a fixed frequency wave of varying duty cycle. Is there any way to ...
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 ...
-2
votes
2answers
534 views

Wi-Fi from Arduino to computer serial COM

I am somewhat new to the Arduino world and so far having fun. I am making a gardening watering system for my first project. I am at the final stages of completion and want to add a Wi-Fi module on the ...
0
votes
1answer
1k views

Making AC current with pin 11

I'm trying to make AC current (50Hz) with an Arduino Uno. It seems to be not working (or wrong code). int up; int down; int out = 11; void setup() { pinMode(out, OUTPUT); Serial.begin(9600); } ...
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 ...
5
votes
1answer
987 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 ...
1
vote
2answers
994 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 ...
2
votes
3answers
641 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 ...
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. ...
0
votes
1answer
902 views

AnalogWrite custom voltage

I want to get a low voltage on output pin of Arduino mega. I have connected Pin 46 to A3, and wrote 120 value to 46 port. Expected was to get 2-3v on A3 input pin. Instead I always get 1023 values as ...
1
vote
1answer
687 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 ...