I am using an Arduino Micro and driving 3 LEDs using TIMER1 and phase correct PWM. I'm not using any prescaler so the PWM frequency is 3.91kHz. The PWM on these 3 LEDs is working perfectly and each LED draws at most 25mA.
I am also using INT6 for an interrupt on a pushbutton, I've got a 10KOhm pull-down resistor and pushing the button will pull the voltage up to 5V.
This pushbutton also works - but when I have one or more of the LEDs running at something other than 0% or 100% duty cycle there is noise on this line that is visible on my oscilloscope. It is always far less than .5V and the "noise" varies when I change the duty cycle of the PWM LEDs. While it doesn't look like much on the scope it is sufficient to trigger the pushbutton rising-edge interrupt despite the button not being pressed. When I do press the button I get a clean pull-up to 5V and while the button is held down I get no spurious readings.
I'm more of a software than a hardware person and am not sure where I would need to add what kind of a filter and am looking for suggestions. I've tried adding decoupling capacitors to the power rail (10uF and 100uF) but that made no difference to the noise.
DDRE &= ~_BV(DDB6); // Make pin E6 an input pin
EIMSK &= ~_BV(INT6); // turn off INT6 interrupts to avoid false readings while changing
EICRB = _BV(ISC60) | _BV(ISC61); // Triggers an interrupt on rising edge of signal
EIMSK |= _BV(INT6); // turn on INT6 interrupts again
ISR(INT6_vect)
{
PINC = _BV(PC7); // Toggle Pin 13 (Arduino Green LED)
} // of interrupt 6 handler
I put in an RC filter and while my oscilloscope showed that smoothed things a bit, I still had the error.
But after playing around a bit, I found that while I'd hooked my oscilloscope and DMM up correctly, the actual pin that I'd plugged the whole assembly into on the Arduino micro was off by 1.... so while I was measuring one circuit the tri-stated unattached pin (pin 7) was merrily bouncing around.
But I'm still glad I posted, as I was stuck in rut before formulating my question and that got me thinking about doing other tests.