Let's Make Robots!

code problem, wiring problem or broken picaxe?

I am a noob so I am sorry if  this is obvious.

I am using a picaxe 20m and having an issue, when I am checking if a switch is high or low (if pin7 = 1 then ...), on all of my inputs except pin7, me touching or being near the wire is enough to flash it between 1 and 0. it is finding enough voltage from my hand to trigger, it will do this even on the simplest codes, any help would be well appreciated.

Thanks in advance
Shane

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

The code you suggest will only turn on the led when input 6 is high and stay on until you reset your chip.

If it`s blinking it suggest that the chip resets and you have some wire fault or your power is to low.

Try:

Main:

If pin6=1 then ledon
if pin6=0 then ledoff
goto main

ledon:
high 7
goto main

ledoff:
low 7
goto main

Thanks for pointing out the error in my code, BUT even with this code it WILL turn off one I move away from it and wont turn on unless I get near it (eg. if I push it with a pen it wont go). could this be static damage? I am suspicious about this as I am rather lax about grounding my self, and I cant see what else could trigger an electrical device over range.

Verify the connection for your serin pin is in fact connected to ground. Do a continuity check on it(use a multimeter). I've run into something similar where this was the culprit....

thanks for the quick responses, this is my circuit, i apologise if my comment about the switch confused people, if I have a switch or not doesn't mater. if I touch the wire leading to the in port and my code = 

Main:
if pin6 = 1 
high 7
goto main

(note that this will happen in ins 1-6 and all outs work perfectly)

the led flickers on and of 2-3 times a second.

Since we're trying ANYTHING - ensure that you're using a normal LED, and not a flashing LED ?

(I've fallen into this trap WAY too many times, best to have flashing LEDS in a separate compartment, but they all look so much like the same damn thing!).

 

Upload a picture of your setup, this will make it easier for others to help you.

How functional are the output pins? can you set them high/low?

You might have done these things already, but we don't know that, so some more info about the things you've tested already might be helpful in a dianosis?

Are you using either pull-up or pull-down resistors on your inputs? If not, do so.

Recheck your connections to the switch, make sure the wires aren't connecting when you touch them.

What type of switch are you using?