Will an LED blink if noone is looking?

I have a baffling conundrum. I've set up a breadboard with an ATtiny13A on it and successfully sent a .hex file to it through AVRdude and an Arduino-as-ISP. The C program does nothing but set pin 5 (PORTB0) as output, set it high, wait two seconds, set it low, wait two seconds, and loop. A long blink, basically. To make it interesting, I'm using a bi-color LED of the 2-lead inverse parallel variety. I set up a voltage divider between +5v and Gnd using a pair of 1K resistors. One lead of the LED goes there, the other to pin 5 on the ATt13. The idea, of course, is that when pin 5 is high, the LED will glow green, and when it's low, it'll glow red.

Here's the problem... left on its own, the LED is mostly off. It may blink erratically, or flicker as if on PWM with a very, very low duty cycle. Mostly it just looks like it's not lit at all. BUT, when I stick the black probe of my DMM on ground, and the red probe on pin 5, suddenly I get my green/red blinking just as expected. Interestingly, when I remove the probes, it turns off again. Probing again starts the cycle over, but appears to reset the AVR. It's like the probes are allowing the AVR to come out of BOD, or serving as a reset pull-up.

Of course, there's a 10K resistor from pin 1 to +5 (reset high), Vcc to +5, Gnd to Gnd, pin 5 to the LED, LED to the center of the voltage divider. The breadboard is being fed by an Uno attached via USB to my laptop. I haven't tried with a wall-wart directly, so I guess that's the next step.

Anyone see anything like this before?

Can you post a photo of it, the schematics and the source code and a link to the led ?

At first glance it seems that the input is open. With the probes, you have a high impedance from the measured pin to ground or you introduce noise. In that case the led lights up.
At second thought, a voltage divider of 5V makes 2.5V. That voltage could be too low for the led.

Heisenberg's uncertainty principle in action?

whats the point of the voltage divider, and whats keeping the led's from sucking whatever they want in terms of current?

The voltage divider is there to provide 2.5v for the LED bias. When pin 5 is high, the LED sees +2.5v on the AVR side, forward biasing the green LED. When pin 5 is low, it sees -2.5v, forward biasing the red LED. The LED is supposed to work at 2.0-2.1v typical, so that should be OK. Here's the Digikey sales page for it:

Here's the code. Note, this is AVR C for use in Atmel Studio. The intended application is simplistic enough that bringing in the whole Arduino kit doesn't make much sense for this project. 64 bytes of SRAM and all...

#include <avr/io.h>
#include <avr/interrupt.h>
#include <inttypes.h>
#include <util/delay.h>

void delay_s(uint16_t seconds);
#define wdt_reset() __asm__ __volatile__ ("wdr")

int main(void)
{
	// Disable interrupts and reset the WDT
	cli();
	wdt_reset();
	
	// If the AVR was reset due to WDT expiration, the WDRF flag will be set.
	// This must be cleared before the WDT configuration can be changed.
	MCUSR &= ~(1<<WDRF);
	
	// Enter timed WDT configuration sequence
	WDTCR = ( (1<<WDCE) | (1<<WDE) );
	
	// Enable WDT to reset the AVR after an 8-second timeout
	WDTCR = 0x00;
	
	// Turn off ADC modules to save power (they're not used)
	PRR = (1<<PRADC);
	
	// Enable global interrupts
	sei();
	
	// Turn off all internal pull-ups and enable outputs
	PORTB = 0x00;
	DDRB = 0x01;
	
    while(1)
    {
        delay_s(2);
        PORTB = 0x01;
        delay_s(2);
        PORTB = 0x00;
    }
}

// Delay for a specific number of seconds
void delay_s(uint16_t seconds) {
	while (seconds > 0) {
		_delay_ms(1000);
		seconds--;
	}
}

Here's a Fritzing snap of the breadboard layout. Powered from the 5v/Gnd pins on an Arduino.

I've since noticed two things:

  1. Probing Gnd and pin 5 shows 0v, 4.88v in time with the 2-sec delays. Probing pin 5 to the center tap of the divider shows -0.02v at all times... which is to say, probably near the error threshold of the meter. No idea why that is.

  2. Moving the Tiny off this breadboard (set up as an incubator solely for use with AVRdude) to the breadboard with the intended project, it behaves as expected. Of course, its final job is not to just blink red and green. The project board has an audio input that fires a transistor when the signal is over a threshold, pulling the INT0 pin low, triggering an interrupt, turning the LED green, and turning on a power amp. This is naturally a much longer program. At any rate, on a board with a half dozen op-amps, a few transistors, and a bunch of other parts, it seems to behave. Maybe because of the multi-output transformer (-12, +12, +5) that is running that board? Not entirely sure.

So, this is more or less solved in the immediate sense, but I still can't explain what happened.

SirNickity:

  1. Probing Gnd and pin 5 shows 0v, 4.88v in time with the 2-sec delays. Probing pin 5 to the center tap of the divider shows -0.02v at all times... which is to say, probably near the error threshold of the meter. No idea why that is.

Maybe it would be a good idea to find out....

Sounds to me like a bad bread board connection that you were making good by the pushing of the probes onto it. Nothing to do with the electrical effect of the meter.

so theres nothing from keeping the led from sucking current, possiblally (doubtfull though) resetting your IC

A pin on an arduino will equally source or sink current. As long as you keep it to the limits of the pin then it has no untoward effect.

Well, the only thing limiting the current to the LED would be the 1K resistors to the +5 and Gnd rails. The divider creates a 2.5v tap with 1K of resistance either direction. That sounds current-limited to me. :slight_smile:

I'm still at a loss for why the probing caused things to change. For that matter, even on the "actual" project breadboard where things otherwise seemed to work just fine, sometimes just touching (only) the black probe to Gnd would cause the uC to reset. Not always, just sometimes.

I'm honestly not sure how "clean" the power is from my little 3-voltage wall-wart supply. It appears to have its own capacitance because all the LEDs on my project fade out when it's unplugged, but for no reason in particular, I didn't put any large electrolytics on this project board like I usually do. There are ceramic caps on the supply pins though. I don't suspect loose connections per se, since it doesn't appear to mind being jiggled or touched.

Thanks for the brainstorming, everyone. This one might remain a mystery though. Well, just for fun, here's a pic of the project board. Everybody loves gratuitous breadboard pics, right? The Tiny is the top right IC next to the single green LED.

bb.jpg

sometimes just touching (only) the black probe to Gnd would cause the uC to reset. Not always, just sometimes.

That suggest it is a mechanical problem rather than an electrical one.

Whilest I hate bread board that one is quite neat, well done.

Osgeld:
so theres nothing from keeping the led from sucking current, possiblally (doubtfull though) resetting your IC

Nothing ... apart from the 1K resistors.

One thing I noticed in calculating the voltage you use 5v, then you say it is powered by a 3v wallwort. What voltage are you getting on the board with the circuit set up?

Not 3V; 3 voltage outputs: +12, -12, +5. It used to terminate on a mini-DIN connector. Some shears and banana plugs later, it's a breadboard supply.