Update analogdemo.cpp

This commit is contained in:
Siwat Sirichai 2023-10-12 19:40:50 +07:00
parent 46ec54355a
commit 8bb4a2ff55
1 changed files with 6 additions and 0 deletions

View File

@ -1,4 +1,5 @@
#include <ESPMegaPRO.h>
#define ADC
void setup()
{
@ -8,9 +9,14 @@ void setup()
void loop()
{
#ifdef DAC
for(int i=0;i<4096;i++) {
ESPMega_dacWrite(0,i);
double dac_val_sine = 2047.5*sin(i*2*PI/2047.5)+2047.5;
ESPMega_dacWrite(1,(int)dac_val_sine);
}
#endif
#ifdef ADC
Serial.printf("A0: %d",ESPMega_analogRead(0));
#endif
}