PICAXE Electronic interference?

<Edit>


I have solved the problem by making two changes.

Firstly, a 22k resistor was put from I/O 2 to ground.

Secondly, I had to modify the program to be the following, and accept any value as an input as long as it was not 0. The new program is shown below:

main:low 1 'discharge led on Pin 1input 2 'make pin 2 an inputreadadc 2, b1 'read pin 2 using ADCif b1 > 0 then flash goto main 'loop back roundflash:'led sequencehigh 1pause 100low 1goto main

</Edit>


I've been having a bit of an odd problem...

I'm trying to use a PICAXE 08M with a touch input, so a user touches a wire or bridges 2 wires and the uC responds based on the program, at the moment, turns an LED on.

Now, Initially, I've tried a few things, until sort of by accident I noticed that using the program I was, the LED turned on by touching the input pin of the PICAXE, with nothing attached to it except one short piece of wire. I know the human body has certain capacitive qualities, but I wouldn't have thought it would be enough for this. The LED started turning on when I got close to the breadboard it was on, never mind the wire.

I tried moving the board, while I had my finger on the wire, and found that when I got a certain distance from my laptop (About 1 ft or so) the LED would go out, and not come on again. Strangely, it does the same when my laptop is turned off!

So what I was wondering is, what could my laptop be doing that enables the PICAXE to get an input from seemingly nothing? Could it be some sort of EM field from it? Incidentally, the same thing happens close to my TV.

The code i'm using is below.
main:low 1 'discharge led on Pin 1input 2 'make pin 2 an inputreadadc 2, b1 'read pin 2 using ADCif b1 < 40 then flash goto main 'loop back roundflash:'led sequencehigh 1pause 100low 1goto main

sort by: active | newest | oldest
NachoMahma9 years ago
. Computers generate a lot of electrical noise. . Keep all wiring as short as possible and reduce the gain of any amplifiers in the sensor circuit. Might help to mount in metal hobby box. . I've never programmed a PIC, but it looks to me as if adjusting "if b1 < 40" might help. Not sure if the number needs to be bigger of smaller.
whatsisface (author)  NachoMahma9 years ago
I think I may have cracked it. Generally, the inputs for a PICAXE are usually connected to +V and then to the pin, but the pin is also grounded by a resistor, whichI have not done. Now the interference seems to have gone away with a 22k from I/O 2 to ground.
. It may help to ground all unused inputs. Check the docs to make sure it's safe to do so. . Just for my curiosity, does adjusting b1 < 40 have more of an effect now?
whatsisface (author)  NachoMahma9 years ago
Yes, the new code above works perfectly, it seems the 40 value was way off, the resistance of the body is so high I need to use any values greater than 0 as an input.
whatsisface (author)  NachoMahma9 years ago
Adjusting that value does have an effect, but when I change it it doesn't seem to do much. I have noticed though, that although the program runs when the programming lead is plugged into the board, it is vastly more sensitive, so i'll have a go at reducing wire lengths. Thanks!