03-21-2023 04:53 AM
Hi All
Thanks in advance.
I am trying to create an IoT design that makes use of the time within Cisco PT , for example if it's past 8am the door is open.
I can't see anywhere or any way of using the time (within the PT file) to action a function
Can anyone confirm if it's even possible? (Im told it is)
Thanks
04-04-2023 06:05 PM
Hi @jk865,
I think it's possible as the time library is being imported in this video
IoT Device Programming using Packet Tracer with Sensors and Actuators - YouTube
You would just need to find a way to set the time, with the date module or find an innovative way
I hope this helps!
04-04-2023 06:56 PM
Yes, it is possible to use the time within Cisco PT to trigger an action in an IoT design. You can use a timer or clock module within Cisco PT to keep track of the time, and then use an if-else statement to check the time and trigger an action based on the time.
For example, you can create a timer module and set it to start at a specific time, say 8am. You can then use an if-else statement to check if the current time is after 8am, and if so, trigger an action to open the door.
Here's some sample code that demonstrates this concept:
makefile
Copy code
timer_start_time = "08:00:00"
current_time = timer.get_time()
if current_time > timer_start_time:
door.open()
This code sets the timer to start at 8am, gets the current time, and then checks if the current time is after 8am. If it is, it triggers the action to open the door.
Of course, you'll need to modify this code to fit your specific IoT design, but this should give you an idea of how to use the time within Cisco PT to trigger an action.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide