I would like to blink, using specific waveforms, 2 LED controlled by the 2 DAC output of the Arduino Due.
I wrote this :
#include "Waveforms.h"
int i = 0;
int sample;
void setup()
{
analogWriteResolution(12);
}
void test(float fq, int wave1, int wave2)
{
sample = ((1/fq)*1000000)/120;
analogWrite(DAC0, waveformsTable[wave1][i]);
analogWrite(DAC1, waveformsTable[wave2][i]);
i++;
if(i == maxSamplesNum)
{
i = 0;
}
delayMicroseconds(sample);
}
void loop() {
// 10 Hz, 0 is a sine wave on DAC0, 3 is a square wave on DAC1
test(10, 0, 3);
I would like to be able to change the frequency of each output (1Hz - 100 Hz) using differents waveforms. Changing waveforms is ok and it works, but is it possible to also change the frequency so to have two differents output frequency on each DAC output ?
The goal is to have, for example, simultaneously :
- 1 Hz, sine wave on DAC0.
- 10Hz, square wave on DAC1.
Thanks a lot.