diff --git a/code/main.py b/code/main.py index ba4b5a79c99d5637e4bb1f37a15c961a6f69e4e3..467ca52e0f4a212143918851f0d9f8668a7fc429 100644 --- a/code/main.py +++ b/code/main.py @@ -6,6 +6,9 @@ spike_duration = 3.5 # spike duration, ms pulse_duration = 500 # dwell (including spike time), ms total_cycle = 3000 # period of the cycle, ms +sd_math = int(spike_duration*1000) +pd_math = int((pulse_duration-spike_duration)*1000) + # establish pins led_pin = Pin(27, Pin.OUT) sol_pin = Pin(29, Pin.OUT) @@ -27,12 +30,12 @@ def pwm_control(timer): # on cycle pwm_led.duty_u16(65535) # set the duty cycle of the led pwm_sol.duty_u16(65535) # set the duty cycle of the solenoid - sleep_us(int(spike_duration*1000)) + sleep_us(sd_math) # pwm cycle pwm_led.duty_u16(hold_duty) # set the duty cycle of the led pwm_sol.duty_u16(hold_duty) # set the duty cycle of the solenoid - sleep_us(int((pulse_duration-spike_duration)*1000)) + sleep_us(pd_math) # off cycle pwm_led.duty_u16(0) # set the duty cycle of the led