John, 1. do you have pull up resister on porta,0. 2. how are you driving the buzzer. you should use a transistor with it. so far is hardware problem unless you didn't mention all this. Andre John Esposito wrote: > I am a beginner at PIC programming and built a test circuit using the > 16C84. The circuit uses a magnetic switch for an input and when the switch > closes, and LED and piezo buzzer turn on. Simple right? Well, not for me! > > Here is the problem: when I physically move closer to the breadboard (with > the mag switch open), the LED turns on (but not the buzzer), getting > brighter as I get closer to the breadboard. Once this happens, the > operation of the circuit is all messed up. If I close the switch, > sometimes the LED goes on, sometimes the buzzer sounds, sometimes both, and > sometimes the LED works opposite, i.e. when the switch is open, the LED is > ON, and vice-versa. > > Brief description on the circuit: 10 MHz Crystal (ECS) w/ 33 pF caps > directly to ground; PORTA<0> switch input, PORTA<1> led output, PORTA<2> > piezo output. > LED output feeds an 74HC04 inverter; output of inverter to LED cathode; LED > anode through 100 ohm resistor to +5V. All unused 74HC04 inputs direct to > ground. All unused PIC I/O are configured as outputs and left unconnected > to anything. !MCLR pulled up to +5V. > > As for hardware, I configure the I/O ports on reset, and basically run a > tight loop scanning the inputs, and changing the outputs based on the > input. > > Any ideas? Hardware or software? I can't do much else until I figure out > what is going on here. > > Thanks in advance for the help. > > --John