PICAXE Electronic interference?
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
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