I am making a project where I use PWM. I want to adjust the timing with two button. I call these two button by help of pin interrupt to toggle up and down. I in/de crement by one (in the calculation DelayAjd = DelayAjd - 1 and DelayAjd = DelayAjd + 1 But every time I press one of the button the counters step up and down with two? If I change cslculation with 2 it change with 4 ?
Works in simulation. My loop in the interrupt I use for "delay" timer to avoid noice. I know it is not good to use delay component in macro called by interrupt.
Here I read both buttons and then adjust DelayAjd - no change if both buttons pressed.
I just print the value to LCD - so 'works' in simulation. Then wait for buttons to be released (or have a delay for value to increase / decrease whilst button held)
It would be nicer - at least in simulation - to use an interrupt. In simulation button presses can be 'missed' (probably whilst waiting for 'low') - but I don't think this will be an issue on hardware which is rather quicker?
I commented in 'Up' where the infinite loop can occur...