Questions tagged [analogwrite]

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

The analogWrite() function is part of the standard Arduino library. It does not allow true digital-to-analog conversion. Rather, it generates a PWM (Pulse Width Modulation) output signal on any compatible pin.

It has the following syntax:

analogWrite(pin, value);

The first parameter identifies the IO pin number to generate the signal on. The second parameter should be in the range 0-255, and specifies the duty cycle to use (0 is 'always off', 255 is 'always on').

Full documentation is available online here: http://arduino.cc/en/Reference/AnalogWrite

Note: Please only use this tag for questions which are specific to the analogWrite() function. For questions about PWM in general, please use the tag.

98 questions
2
votes
1 answer

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 OUTPUT PORTB |= B00100000; //set PIN13 HIGH but…
wotesi
  • 123
  • 2
2
votes
1 answer

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 classic arduinos(atmega chips) and the new…
Jack
  • 213
  • 2
  • 10
2
votes
3 answers

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 with an analog pin. I was wondering if there is…
Rip Leeb
  • 377
  • 1
  • 10
1
vote
1 answer

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's stopping. When I becomes 250 it's starting at…
Lary
  • 13
  • 2
1
vote
1 answer

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 Monitor it appeared that the values that were being…
Sasha
  • 111
  • 1
1
vote
2 answers

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, OUTPUT); // sets the pin as output } void…
1
vote
2 answers

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?
Wilson Lau
  • 13
  • 3
1
vote
1 answer

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 to have a least 12Bit) that I want create with…
FooTheBar
  • 182
  • 1
  • 1
  • 7
0
votes
2 answers

How can I create an 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 AnalogWrite() to create such type of signal?
0
votes
2 answers

Non-blocking strobing code?

I'm trying to figure out how to create some non-blocking code to strobe some RGB leds with analogwrite 7 times a second; I'm really not to sure how to go about this. If anybody could give me some help that'd be great! :)
Sam W
  • 199
  • 4
  • 11