I need to Simulate Saw-Tooth voltage (4.5 - 0.5V) a total of 30 times . And I don't know how to do it only with python scripts without special library or something. I have this function, but how I do it to work?
def PWM(t, frequency, dutyCycle):
#period = 1 / frequency
#pt = tt / period
pt = tt * frequency # "period" time, where 1 unit is 1 period on the "real" time stamp.
tc = pt - trunc(pt) # cycle time within 1 period. 0..1.
return 1 if tc < dutyCycle else 0 # where 1 means on and 0 means off
