I just got an electron [rev 4.8 ]and am exploring its capability to operate the built in DAC
The code I am using compiled and loaded but has some unusually long delays.|
from Analog write to successive analogWrites is 5 milliseconds. There are no delay calls in the loop. Surely an if statment can’t be using up so much time. I have done a similar program on the slower Teensy processor and it whizzes by
The time LED2 is on is 45usec
Between analogWrites is 5 milliseconds. What is using up the time?
CODE
int dacval =0;
int led1 = D6;
int led2 = D7;
void setup() {
pinMode(DAC1, OUTPUT);
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
}
void loop() {
digitalWrite(led2, HIGH);
pinMode(DAC1, OUTPUT);
analogWrite(DAC1, dacval);
digitalWrite(led2, LOW);
if (dacval >4093){
dacval=0;
digitalWrite(led1, HIGH);
delay(1000);
digitalWrite(led1, LOW);
}
//delay(100);
dacval++;
}