Skip to content
View Namitharangaswamy's full-sized avatar

Block or report Namitharangaswamy

Block user

Prevent this user from interacting with your repositories and sending you notifications. Learn more about blocking users.

You must be logged in to block users.

Please don't include any personal information such as legal names or email addresses. Maximum 100 characters, markdown supported. This note will be visible to only you.
Report abuse

Contact GitHub support about this user’s behavior. Learn more about reporting abuse.

Report abuse
Namitharangaswamy/README.md
  • 👋 Hi, I’m @Namitharangaswamy
  • 👀 I’m interested in ...
  • 🌱 I’m currently learning ...
  • 💞️ I’m looking to collaborate on ...
  • 📫 How to reach me ...

import time

class TrafficLightControlSystem: def init(self): # Define traffic light states self.states = ['Green_NS', 'Yellow_NS', 'Red_NS', 'Green_EW', 'Yellow_EW', 'Red_EW'] self.current_state = 'Green_NS' self.state_timings = {'Green_NS': 10, 'Yellow_NS': 3, 'Red_NS': 10, 'Green_EW': 10, 'Yellow_EW': 3, 'Red_EW': 10}

def transition_to(self, new_state):
    print(f'Transitioning from {self.current_state} to {new_state}')
    self.current_state = new_state

def run_traffic_light_system(self):
    try:
        while True:
            self.transition_to('Yellow_NS')  # Transition from Green_NS to Yellow_NS
            time.sleep(self.state_timings['Yellow_NS'])

            self.transition_to('Red_NS')  # Transition from Yellow_NS to Red_NS
            time.sleep(self.state_timings['Red_NS'])

            self.transition_to('Green_EW')  # Transition from Red_NS to Green_EW
            time.sleep(self.state_timings['Green_EW'])

            self.transition_to('Yellow_EW')  # Transition from Green_EW to Yellow_EW
            time.sleep(self.state_timings['Yellow_EW'])

            self.transition_to('Red_EW')  # Transition from Yellow_EW to Red_EW
            time.sleep(self.state_timings['Red_EW'])

            self.transition_to('Green_NS')  # Transition from Red_EW to Green_NS
            time.sleep(self.state_timings['Green_NS'])

    except KeyboardInterrupt:
        print("Simulation stopped by the user.")

if name == "main": traffic_system = TrafficLightControlSystem() traffic_system.run_traffic_light_system()

Popular repositories Loading

  1. HacklabEmbeddedAssignment_1 HacklabEmbeddedAssignment_1 Public

  2. Namitharangaswamy Namitharangaswamy Public

    Config files for my GitHub profile.

  3. Greendzine Greendzine Public

    LED blinking code Using Arduino