Zeroplus Arduino starter kit with Logic Analyzer Manual page 69

Table of Contents

Advertisement

CODE EXPLANATION
unsigned long currentMillis = millis() When called, this function
returns the number of milliseconds elapsed since the program
started.
if(soundSensor == 1){
soundLed = HIGH;
soundStartTime = currentMillis.
}
If the sensor detects a sound, we set the flag SoundLed. We also save
the time it occurred.
if(soundLed == HIGH){
soundCurrentTime = currentMillis;
if((soundCurrentTime - soundStartTime) >= timeInterval){
soundLed = LOW;
}
This portion of code calculates the elapsed time between now and the
last sound detected by the sensor. This way we can keep the LED lit
for a certain time before turning it off
.
[1]
68

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the Arduino starter kit with Logic Analyzer and is the answer not in the manual?

Subscribe to Our Youtube Channel

Table of Contents