question about dac for adruino nano

hello there. i am thinking of buying dac to convert the pwm output. do i understand it right that as analogWrite takes values from 0 to 255, an 8bit dac is enough? or do i have a general misunderstanding about this?

thanks for any input

A DAC has nothing to do with PWM or analogWrite.
You just write directly to the DAC.
That could be with I2C or SPI.
Leo..

Some boards like the Arduino Due have a onboard DAC that can be written to using the analogWrite function. There is a function that lets you set the resolution. Default is 8bit for compatibility reasons.

DAC and PWM both can be used to create analog Voltages. In case of the PWM you always need a filter if you want a clean analog signal to remove the base frequency of the PWM module. Sometimes this is the energy sink itself e.g. a motor is an inductive filter.

Which one is right for you, depends on your application. Most of the time in embedded PWM are good enough and have advantages when it comes to special requirements for motors e.g. dead time insertion. Some sound applications use special DAC.

Perhaps some basics might help.

The arduino digital output:

  1. can only be low (logically = 0 & voltage could be 0 v ) or high (logically = 1 & voltage could be 5V)

  2. has two different "modes":
    a) Digital where you send it a 0 or 1 and the output goes to 0 0r 1
    b) Analog where the output is NOT really analog but a PWM that will seem like an analog if you average the output.

A DAC is a device that you send a number to (for an 8 bit DAC the number will be between 0 and 255) the output will go to a voltage, basically any voltage between 0 and 5V.

I've made some simplifications but I hope this helps you get the big picture.