I currently have a loop that runs without a time condition:
unsigned long previousMillis = 0; // will store last time LED was updated
int WET=4;//wet line
int DRY=5;//dry line
int Inhale=1000;//msec
int Exhale=1000;//msec
//int Noflow=3000;//msec
void setup() {
// put your setup code here, to run once:
pinMode (WET, OUTPUT);
pinMode (DRY, OUTPUT);
}
void loop() {
//inhale
digitalWrite(WET,LOW);
digitalWrite(DRY,HIGH);
delay (Inhale);
//exhale
digitalWrite(WET,HIGH);
digitalWrite(DRY,LOW);
delay (Exhale);
//No flow
//digitalWrite(WET,HIGH);
//digitalWrite(DRY,HIGH);
//delay (Noflow);
}
Then i have tried to code a "timer" for each cycle,but i got error:" exit status 1 Error compiling for board Arduino/Genuino Uno."
Code with timer:
unsigned long previousMillis = 0; // will store last time LED was updated
int WET = 4; //wet line
int DRY = 5; //dry line
//int Inhale=1000;//msec
//int Exhale=1000;//msec
//int Noflow=1000;//msec
int BPM = 60;
int IE = (((60 * 1000) / BPM) / 2);
void setup() {
// put your setup code here, to run once:
pinMode (WET, OUTPUT);
pinMode (DRY, OUTPUT);
}
void loop() {
for (int i = 0; i = 20;)
int BPM = BPM + 10;
#include <elapsedMillis.h>
elapsedMillis timeElapsed;
unsigned int interval = 60000; //one minute in ms
while (timeElapsed < interval) {
//inhale
digitalWrite(WET, LOW);
digitalWrite(DRY, HIGH);
delay (IE);
//exhale
digitalWrite(WET, HIGH);
digitalWrite(DRY, LOW);
delay (IE);
//No flow
//digitalWrite(WET,HIGH);
//digitalWrite(DRY,HIGH);
//delay (2000);
}
}
Target ouput: to run every cycle of the loop for 1 min.
Any one familiar with this error? Many thanks for your help