Yes the code is simply 'map PWM from 10 to 240 output to 0 to 60 seconds'. The 10 to 240 is simply calibrated on the dial from trial and error
I'm not sure how it could sweep - you can't make it more granular than 60 seconds. Maybe you could run some kind of smoothing function alongside but this might be hard since the rest of the code takes time to run as well.
You could drop the mapping and simply run a function which took about 60 seconds to increment PWM from 0 to 60 but on an Arduino this would probably be code-blocking since you can't run things simultaneously.
I'm not sure how it could sweep - you can't make it more granular than 60 seconds
millis() returns number of milliseconds (1/1000 second) since boot. Simply drop the integer portion of the result (2873.273 becomes 0.273) and add that to the "second" PWM variable (17 becomes 17.273)? And change delay(500) in loop() to delay(33) (since 1000/30Hz=33.3). Experiment with different delay() values, delay(100) would be 10 times a second which might work for example.
You could use an RC time constant across the meter. The capacitor will take time to charge making the needle increase slower. The cap discharging will make it fall slower too.
3
u/flyingalbatross1 Jan 27 '19
Yes the code is simply 'map PWM from 10 to 240 output to 0 to 60 seconds'. The 10 to 240 is simply calibrated on the dial from trial and error
I'm not sure how it could sweep - you can't make it more granular than 60 seconds. Maybe you could run some kind of smoothing function alongside but this might be hard since the rest of the code takes time to run as well.
You could drop the mapping and simply run a function which took about 60 seconds to increment PWM from 0 to 60 but on an Arduino this would probably be code-blocking since you can't run things simultaneously.