Go Down

Topic: Simple DAC output (Read 980 times) previous topic - next topic

yazdani_bd

Hi I'm really new in Arduino.. I'm just trying to get two DAC output from Arduino with one for minimum and another for maximum. can you please help me. to write the code for that.

Thanks in advance

Grumpy_Mike


MarkT

You can increase the resolution from the default of 8 bit (upto 12 bits) using the
Code: [Select]
analogWriteResolution(12) ;


And then provide values from 0.. 4095 to analogWrite().

Thus:
Code: [Select]

void setup()
{
  analogWriteResolution (12) ;
}

void loop()
{
  for (int i = 0 ; i < 4096 ; i++)
  {
    analogWrite (DAC0, i) ;
    delayMicroseconds (100) ;
  }
}


(The Due native DAC resolution is 12 bits, the default at start up is only 8 to be
compatible with other Arduinos)
[ I won't respond to messages, use the forum please ]

yazdani_bd

Thanks a lot for the help. it worked.

Go Up