Arduino Due DAC Tutorial Problem


I'm trying to run a tutorial I found on the arduino site, here, using the due:

The compiler returns an error with the example code: 't_sample' was not declared in this scope

My frustration is that the variable declared directly above it seems to work just fine. What's the problem here? Is the compiler broken?

Here's the beginning of the program listed on the tutorial:

include "Waveforms.h"

define oneHzSample 1000000/maxSamplesNum // sample for the 1Hz signal expressed in microseconds

const int button0 = 2, button1 = 3; volatile int wave0 = 0, wave1 = 0;

int i = 0; int sample;

void setup() { analogWriteResolution(12); // set the analog output resolution to 12 bit (4096 levels) analogReadResolution(12); // set the analog input resolution to 12 bit

attachInterrupt(button0, wave0Select, RISING); // Interrupt attached to the button connected to pin 2 attachInterrupt(button1, wave1Select, RISING); // Interrupt attached to the button connected to pin 3

sample = 0; }

void loop() { // Read the the potentiometer and map the value between the maximum and the minimum sample available // 1 Hz is the minimum freq for the complete wave // 170 Hz is the maximum freq for the complete wave. Measured considering the loop and the analogRead() time sample = map(analogRead(A0), 0, 4095, 0, oneHzSample); sample = constrain(t_sample, 0, oneHzSample);

analogWrite(DAC0, waveformsTable[wave0]); // write the selected waveform on DAC0 _ analogWrite(DAC1, waveformsTable[wave1]); // write the selected waveform on DAC1_

Just remove the t_ from the name. It is the value from the previous line that is (supposed) to be constrained.

Can't believe I missed that. Thanks.

If you like the sounds that makes, here is a very similar but slightly more complex approach that make a far more entertaining set of sounds. Justvbe very careful what you connect your DAC output to, a few of us have burned them out.

Duane B