Pages: [1]   Go Down
Author Topic: Simple DAC output  (Read 932 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 627
Posts: 34246
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Just use the analogWrite function
http://arduino.cc/en/Reference/analogWrite
Logged

0
Offline Offline
Shannon Member
****
Karma: 207
Posts: 12200
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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

Thus:
Code:
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)
Logged

[ I won't respond to messages, use the forum please ]

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks a lot for the help. it worked.
Logged

Pages: [1]   Go Up
Jump to: