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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
};
void loop()
{
matrix.renderBitmap(smile, 8, 12);
delay(1000);
matrix.renderBitmap(wink, 8, 12);
delay(1000);
matrix.renderBitmap(cry, 8, 12);
delay(1000);
}
void setup()
{
analogWriteResolution(8); // set the analog output resolution to 12 bit (4096 levels)
}
void loop()
{
analogWrite(DAC, 171); // write the selected waveform on DAC0
}
#ifndef _Waves_h_
#define _Waves_h_
static int waveformsTable[120] = {
0x22, 0x44, 0x66, 0x88, 0xaa, 0xcc, 0xee, 0x110, 0x132, 0x154,
0x176, 0x198, 0x1ba, 0x1dc, 0x1fe, 0x220, 0x242, 0x264, 0x286, 0x2a8,
0x2ca, 0x2ec, 0x30e, 0x330, 0x352, 0x374, 0x396, 0x3b8, 0x3da, 0x3fc,
0x41e, 0x440, 0x462, 0x484, 0x4a6, 0x4c8, 0x4ea, 0x50c, 0x52e, 0x550,
0x572, 0x594, 0x5b6, 0x5d8, 0x5fa, 0x61c, 0x63e, 0x660, 0x682, 0x6a4,
0x6c6, 0x6e8, 0x70a, 0x72c, 0x74e, 0x770, 0x792, 0x7b4, 0x7d6, 0x7f8,
0x81a, 0x83c, 0x85e, 0x880, 0x8a2, 0x8c4, 0x8e6, 0x908, 0x92a, 0x94c,
0x96e, 0x990, 0x9b2, 0x9d4, 0x9f6, 0xa18, 0xa3a, 0xa5c, 0xa7e, 0xaa0,
0xac2, 0xae4, 0xb06, 0xb28, 0xb4a, 0xb6c, 0xb8e, 0xbb0, 0xbd2, 0xbf4,
0xc16, 0xc38, 0xc5a, 0xc7c, 0xc9e, 0xcc0, 0xce2, 0xd04, 0xd26, 0xd48,
0xd6a, 0xd8c, 0xdae, 0xdd0, 0xdf2, 0xe14, 0xe36, 0xe58, 0xe7a, 0xe9c,
0xebe, 0xee0, 0xf02, 0xf24, 0xf46, 0xf68, 0xf8a, 0xfac, 0xfce, 0xff0
};
static int wave_sin[256] = {
0x80,0x83,0x85,0x88,0x8A,0x8D,0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0x2D,0x2F,0x30,0x32,0x34,0x35,
0x37,0x39,0x3B,0x3D,0x3F,0x41,0x43,0x45,
0x47,0x49,0x4B,0x4D,0x4F,0x52,0x54,0x56,
0x59,0x5B,0x5D,0x60,0x62,0x65,0x67,0x69,
0x6C,0x6E,0x71,0x73,0x76,0x78,0x7B,0x7D
};
#endif
主函数代码
#include "Waves.h"
int i = 0;
void setup()
{
analogWriteResolution(8); // set the analog output resolution to 12 bit (4096 levels)
}
void loop()
{
analogWrite(DAC, wave_sin[i]); // write the selected waveform on DAC0
i++;
if (i == 256) // Reset the counter to repeat the wave
i = 0;
delayMicroseconds(10); // Hold the sample value for the sample time
}
#include "Waves.h"
#include <OPAMP.h>
int i = 0;
void setup()
{
OPAMP.begin(OPAMP_SPEED_HIGHSPEED);
analogWriteResolution(8); // set the analog output resolution to 12 bit (4096 levels)
}
void loop()
{
analogWrite(DAC, wave_sin[i]/2); // write the selected waveform on DAC0
i++;
if (i == 256) // Reset the counter to repeat the wave
i = 0;
delayMicroseconds(10); // Hold the sample value for the sample time
}
#include "Waves.h"
#include <OPAMP.h>
int i = 0;
void setup()
{
OPAMP.begin(OPAMP_SPEED_HIGHSPEED);
analogWriteResolution(8); // set the analog output resolution to 12 bit (4096 levels)
analogReadResolution(8); //change to 14-bit resolution
Serial.begin(9600);
}
void loop()
{
analogWrite(DAC, wave_sin[i]/2); // write the selected waveform on DAC0
i++;
if (i == 256) // Reset the counter to repeat the wave
i = 0;
int reading = analogRead(A4); // returns a value between 0-16383
delayMicroseconds(10); // Hold the sample value for the sample time
Serial.print(reading);
Serial.print("\n");
}