VERY simple 08m Question about If-Then/flashing LED

hokieed

New Member
Hi Everyone.

I tried some simple searches for my problem with no luck. So, I hope you can help really quick. Thanks in advance.

I have a very simple circuit on a breadboard that simply flashes an LED. The program is supposed to look for a contact closure on Pin 3 and then go to a subroutine to flash the LED, then return to the main and look for the contact closure again.

The problem is that as soon as I apply power, the LED starts to flash in the subroutine and will not stay in the main.

Here is the program:

main:
if pin3 = 1 then flash
goto main

flash:
high 4
pause 500
low 4
pause 500
high 4
pause 500
low 4
goto main


This is probably the simplest way for me to flash the LEDs on pin4 without anything fancy.


Right now, pin3 is open. when I apply power, the led starts to flash regardless of what I do to pin3. Someitmes, the led stops flashing. So, then, I just jumper 5 volts form my main power to pin3 adn the flahsing starts.... but many times, it doesnt stop for 3-4+ cycles. Seems too touchy.

When I tested pin3 with a voltmeter, I see a very small voltage of .01-.03 volts. Is this enough to trigger pin3 as on?

should I be initializing pin3 as input or something?


This just seems so simple and I'm not sure why it is a problem. Thanks again for any help.
 

Ralpht

New Member
When you say a contact closure on pin 3, I assume you are usuing a switch?

Since you want to activate the subroutine when pin 3 goes high, do you have a resistor from pin 3 to ground connected or is pin 3 "floating" (no connection when there is no contact closure.

If floating then its operation can be very erratic. Inputs should always be set to known states first.

This may explain the erratic operation you are having.

Please post a circuit of what you have actually connected.
 

hokieed

New Member
Um.. yeahhhhh, slight oversight on my part

You are exactally correct. after posting and walking away for a while, I revisited my circuit and realized the eoor of the floating input like you mention. Added the resistor to ground on that pin and problem solved.

Now, I just need to delete this thread and save myself the embarrassment.

Thanks for your reply. Perhaps another newbie will learn something from this too.
 

RogerTango

Senior Member
I revisited my circuit and realized the eoor of the floating input like you mention. Added the resistor to ground on that pin and problem solved.
Dont feel bad, the first time I hooked up a switch, nothing worked right... I did the same thing. After pinning down with R to GND, everyone worked slick as silk!

Keep going, the fun is just starting... there is SOOO much that you can do with these things, its addictive!

Andrew
 

Ralpht

New Member
hokieed,

No embarrasement needed or required.
If you don't stuff up you don't learn anything.

We have all been there and done that. The embarrising part comes after you have years of experience and then turnaround and do the same silly thing because of complaceny.

Been there more time than I'd admit :eek:

Enjoy the world that hase opened up for you
 

sid

Senior Member
You are exactally correct. after posting and walking away for a while, I revisited my circuit and realized the eoor of the floating input like you mention. Added the resistor to ground on that pin and problem solved.

Now, I just need to delete this thread and save myself the embarrassment.

Thanks for your reply. Perhaps another newbie will learn something from this too.
I exactly the same thing on my first picaxe project a week ago,
So your not alone, a man who never made mistakes, never made anything
 
Top