You have to invert the flow slightly because you can't just kick off a process when the deadline arrives.
You can (and should) restrict the voting to the period when the election is open. That is, don't allow any voting after the deadline. You can also return a bool
to indicate open/closed status, so clients can know if the election is open or closed.
modifier onlyIfOpen {
require(isOpen());
_;
}
function isOpen() public view returns(bool isIndeed) {
return now < deadlinel;
}
You can also optionally return a winner.
function blueTeamIsWinner() public view returns(bool isIndeed) {
return blueCount > redCount;
}
Everything is predicated on the client inspecting the contract rather than launching a process on a schedule.
Hope it helps.