While reading your code i noticed a part that might be part of your issue. Right after your comment line to check if a person or face was detected in the previous second your loop checks if the time since the last detection is less then a second and if it is then it checks for if a person or a face is detected and if not there is an else statement to make the light green. However there's no if statement preventing this if statement from occurring if nothing is detected meaning it occurs nonstop so the if statement always occurs less then a second from the previous detection resulting in in always returning true preventing the else statement from ever occurring and henceforth preventing the green light from ever appearing. This really fast loop with no waiting whatsoever may also be causing miscalculations and possibly resulting in your red and turquoise lights being on the fritz. It's always good practice to include a wait of somekind in a loop