Input pin always at 3.3v

Hi All,

This mystery is driving me crazy.

I am using an ATmega328P-PU in standalone, 8 MHz internal, 3.3 V configuration on my custom PCB. The digital pins 1 and 4 (physical 3 and 6 on the IC respectively) are my input pins pulled down by 10K external resistors. I have setup pinMode(pin, INPUT) for both.

Now when the circuit is powered on, this pin 1 is always at 3.3V for some mysterious reason, whereas pin 4 is behaving normally. And as I mentioned I am using external pull down resistors. I checked the whole PCB many times over, but I dint find any issue there.

And when I remove the ATmega328P from my PCB and power it on, I don't get this 3.3V on the same pin on the IC base.

One of the output pins on ATmega328P is connected to an LED which lights up as expected, so I guess the sketch is running just fine.

Please help me out here! I am about to go insane :) .


Does your sketch include a call to Serial.begin()?

Pin1 is used for the hardware serial port's TX; when idle it's driven HIGH - so if the UART is enabled, pin1 is driven high. The UART functionality overrides normal function of the pin.

Note that the bootloader also uses serial, so unless you're programming via ISP, even if your sketch doesn't enable serial, the bootloader will (briefly) enable it. Also, if that pin is externally driven, it can prevent loading of sketches, and possibly even damage the pin (due to excessive current if you were externally grounding it while the chip was trying to use it for serial)

In summary, use a different pin, or program via ISP (w/out the bootloader) and don't use serial.

Thanks spycatcher2k and DrAzzy for the quick response.

DrAzzy I think you caught the issue right away as I am using serial.begin for reading an IR receiver. I'll try one of your solutions when I get home. My circuit controls power to a Raspberry-pi using a relay. I turn it on using an IR remote and read current status of the Pi through pin1. Now since the pcb is a custom one, I don't have an option of using a different pin, I'll have to cut some tracks and drill some holes to do that. So I'll have to let go of the IR remote and remove serial.begin for now :-( , unless there is a way of reading a single IR command without serial. Thanks for the help. You saved me from another sleepless night. :-)

Hi DrAzzy ,

I did the following,

  1. Removed hardware serial calls from the sketch. Now Pin 1 stays LOW.
  2. Added a Software serial on two unused pins for the IR. IR remote is able to turn on the relay.

Things are running perfectly now.
Thanks a lot for the guidance.
See you around with more questions. :smiley: