Skip to content

Instantly share code, notes, and snippets.

@shyampurk
Created June 29, 2018 09:15
Show Gist options
  • Save shyampurk/42a4156bdee512f53e8c023f1393d000 to your computer and use it in GitHub Desktop.
Save shyampurk/42a4156bdee512f53e8c023f1393d000 to your computer and use it in GitHub Desktop.
def updateTrafficSignal():
global trafficLightNormalCurrState
state = emergencyVehicleState["state"]
if state == NORMAL:
if (LIGHT_RED == trafficLightNormalCurrState):
print "Switching to RED\n"
set_red()
elif (LIGHT_YELLOW == trafficLightNormalCurrState):
print "Switching to YELLOW\n"
set_yellow()
elif (LIGHT_GREEN == trafficLightNormalCurrState):
print "Switching to GREEN\n"
set_green()
time.sleep(trafficLightNormalCycleTime[trafficLightNormalCurrState])
trafficLightNormalCurrState = trafficLightNormalCycle[ (trafficLightNormalCurrState + 1) % 3]
elif state == CRITICAL:
set_green()
print "Detected Critical Distance from Emergency Vehicle\n"
print "Switching to GREEN and Hold\n"
time.sleep(3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment