import time
import random
def simulate_rc_time():
"""
Simulate the behavior of an RC circuit with high and low counts
alternating at specific intervals.
"""
current_time = time.ticks_ms() // 1000 # Get current time in seconds
# Simulate high values for 5 seconds, then low values for 5 seconds
if current_time % 10 < 5: # First 5 seconds of each 10-second interval
return random.randint(500, 1000) # Simulate high count
else: # Next 5 seconds of each 10-second interval
return random.randint(0, 100) # Simulate low count
# Main loop
try:
while True:
simulated_count = simulate_rc_time()
print(simulated_count) # Output the simulated count
time.sleep(0.1) # Delay to mimic real readings
except KeyboardInterrupt:
print("Program interrupted.")