0

I would like to use pins RXD and TXD (PD0 and PD1 in ATmega328p) as inputs. I am using Arduino Uno to upload a code to my ATmega328p, after that I plug in ATmega to my circuit board. Arduino Uno is connected to the laptop using USB cable.

2 buttons are on the circuit board:
First button connected to PD0, second connected to PD1.

My code looks like this:

#define NEXT 0
#define PREVIOUS 1

void setup()
{
    pinMode(NEXT, INPUT);
    pinMode(PREVIOUS, INPUT);
}

void loop()
{
    if(digitalRead(NEXT) == LOW)
    {
        //show something on display
    }
    if(digitalRead(PREVIOUS) == LOW)
    {         
        //show something on display
    }
}

Buttons have pull-up resistors 10k Ohm, when I do not click them they are in HIGH state, then I click the button and they are in LOW.

Problem is that nothing does happen when I click the buttons, even if I write simple code to show a symbol on display.

I read on the internet it's possible to use TX and RX pins as I/O, but they are not working for me, shame is I chose RX and TX as my inputs (all the other pins are free, I just didn't know TX and RX is used for Serial communication).

I would appreciate any advice if I can use those pins, or my circuit should be modified.

  • Your problem is not the pin choice. Can you program your ATmega to do a trivial task, like blinking an LED? – Edgar Bonet Jun 27 '18 at 16:04
  • Thank you for response ! I do not have any LED at the moment, but Atmega is in a DIP soldered to the board. What exactly you would like me to check ? Atmega itself or those 2 pins ? – Robert Maciączyk Jun 27 '18 at 16:16
  • The ATmega and the way it is programmed, powered and clocked. Printing any text on the display would be a good test. – Edgar Bonet Jun 27 '18 at 17:13
  • Do you have a display connector to the Arduino? As long as you don't call Serial.begin(...), you can use pins 0 and 1 as normal GPIOs. – Gerben Jun 27 '18 at 17:50
  • I do not use Serial.begin(), I read that it has to be removed from the code to make those pins working. I did print any text on display, but without using buttons. The only problem I have is with buttons. Good to know those pins can be used as inputs, I will try to figure out what's going on. Thanks for now, will come back here in case I cant figure it out. – Robert Maciączyk Jun 27 '18 at 19:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.