Arduino Forum

Products => Arduino Due => Topic started by: braveneuroworlds on Aug 17, 2016, 08:28 pm

Title: Waveform output on Due
Post by: braveneuroworlds on Aug 17, 2016, 08:28 pm
Hello all,

I'm trying to output a custom waveform from my Arduino Due but am having some issues. I'm trying to do something fairly simple but the Simple Waveform Generator ( isn't very intuitive and seems to be missing some code (unless I'm really mistaken).

I only want to output a single waveform so I'm trying to avoid dealing with libraries and I don't need to adjust the frequency.

When I try and run the example code given in the tutorial linked above, it says that DAC0 wasn't declared in the scope. This even happens when I attempt to declare it.

Can someone give me some insight on how to actually use the DAC0 and DAC1 pins? Thanks!
Title: Re: Waveform output on Due
Post by: MorganS on Aug 17, 2016, 08:39 pm
Just use analogWrite...
Code: [Select]
  pinMode(DAC0, OUTPUT);
  analogWrite(DAC0, a);[/a]
If it's complaining that DAC0 isn't defined then double-check you have the correct board selected on the Tools menu.

Note the pinMode isn't strictly necessary as analogWrite checks that anyway.