I'm trying to get mind around this problem. Possibly I may be taking an incorrect approach.
I would like to make a dog detector so if a dog hasn't hasn't been for 10 second (inactivity), the program would turn off a light. The idea is to run a specific function after a specific period of inactivity based on an if condition.
The goal is to run this code without interfering with the main program. I understand i could use threads. However, my current approach is still interferes my program /sensors.
My Approach (pseudo-code)
if(detect_object == dog){
std::cout << "Dog detected";
}else{
std::this_thread::sleep_for(std::chrono::seconds(10));
//Turn light off
//If Dog is not detected after 10 seconds. After waiting 10 seconds turn light off. Without delaying the the program
std::cout << "Dog not detected, turning light off";
}
Thank you!
Aucun commentaire:
Enregistrer un commentaire