from machine import Pin,PWM,ADC; from utime import sleep,ticks_ms,ticks_diff; b=Pin(13,Pin.IN,Pin.PULL_UP); r=Pin(12,Pin.OUT); c=0; pwm=None; t0=ticks_ms(); p2=PWM(Pin(4),freq=1000,duty=5); a=ADC(Pin(32),atten=ADC.ATTN_11DB); exec("while 1:\n if not b.value():\n sleep(.3); c+=1; print('Button pressed',c,'times'); t=ticks_ms(); pwm.deinit() if pwm else None; pwm=PWM(r,freq=1,duty=500) if not pwm else None\n if pwm and ticks_diff(ticks_ms(),t0)>999:\n t0=ticks_ms(); open('output.txt','a+').write('\\n %.2f V // %d s'%(a.read_uv()/1e6,(ticks_ms()-t-302)//1000))")